car
This commit is contained in:
parent
4c598e7e64
commit
ec9315fe83
|
@ -1,8 +1,7 @@
|
||||||
/* (TEMPLATE )Bot config file; edit this to your liking */
|
/* (TEMPLATE )Bot config file; edit this to your liking */
|
||||||
/* Make sure to rename this to config.ts */
|
/* Make sure to rename this to config.ts */
|
||||||
export default
|
export default {
|
||||||
{
|
prefix: "X",
|
||||||
prefix: "X",
|
token: "X",
|
||||||
token: "X",
|
owner: "X"
|
||||||
owner: "X"
|
|
||||||
}
|
}
|
||||||
|
|
36
package.json
36
package.json
|
@ -1,20 +1,20 @@
|
||||||
{
|
{
|
||||||
"name": "vanilje",
|
"name": "vanilje",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.11.19",
|
"@types/node": "^20.11.19",
|
||||||
"@types/ws": "^8.5.10",
|
"@types/ws": "^8.5.10",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"concordia": "^12.5.5"
|
"concordia": "^12.5.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { Message } from "concordia";
|
import { Message } from "concordia";
|
||||||
|
|
||||||
export default
|
export default {
|
||||||
{
|
name: 'goodnight',
|
||||||
name: 'goodnight',
|
description: 'i lost hours of sleep to ts',
|
||||||
description: 'i lost hours of sleep to ts',
|
execute(msg: Message, args: string[]) {
|
||||||
execute(msg: Message, args: string[])
|
msg.reply('good night.');
|
||||||
{
|
}
|
||||||
msg.reply('good night.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
68
src/index.ts
68
src/index.ts
|
@ -4,59 +4,51 @@ import cfg from "../config";
|
||||||
import { ActivityType, Client, Collection, Message } from "concordia";
|
import { ActivityType, Client, Collection, Message } from "concordia";
|
||||||
import fs from "node:fs"
|
import fs from "node:fs"
|
||||||
|
|
||||||
class CommandClient extends Client
|
class CommandClient extends Client {
|
||||||
{
|
commands: Collection<string, any>;
|
||||||
commands: Collection<string, any>;
|
constructor() {
|
||||||
constructor()
|
super();
|
||||||
{
|
this.commands = new Collection<string, any>();
|
||||||
super();
|
}
|
||||||
this.commands = new Collection<string, any>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const client = new CommandClient();
|
const client = new CommandClient();
|
||||||
|
|
||||||
/* Command Handling */
|
/* Command Handling */
|
||||||
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
|
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
|
||||||
for (const file of commandFiles)
|
for (const file of commandFiles) {
|
||||||
{
|
const command = require(`./commands/${file}`).default;
|
||||||
const command = require(`./commands/${file}`).default;
|
// set new item in collection with key as command name & value as exported module
|
||||||
// set new item in collection with key as command name & value as exported module
|
client.commands.set(command.name, command);
|
||||||
client.commands.set(command.name, command);
|
console.log(command);
|
||||||
console.log(command);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Bot start-up & continued behaviour */
|
/* Bot start-up & continued behaviour */
|
||||||
function onReady(): void
|
function onReady(): void {
|
||||||
{
|
client.user!.setPresence({
|
||||||
client.user!.setPresence
|
activity: { name: 'with my balls.' },
|
||||||
({
|
status: 'idle'
|
||||||
activity: { name: 'with my balls.'},
|
});
|
||||||
status: 'idle'
|
console.log("Logged in!");
|
||||||
});
|
|
||||||
console.log("Logged in!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMessage(msg: Message): void
|
function onMessage(msg: Message): void {
|
||||||
{
|
if (msg.author.bot || !msg.content.startsWith(cfg.prefix))
|
||||||
if ( msg.author.bot || !msg.content.startsWith(cfg.prefix) )
|
return;
|
||||||
return;
|
|
||||||
|
|
||||||
const args: string[] = msg.content.slice(cfg.prefix.length).trim().split(/ +/);
|
const args: string[] = msg.content.slice(cfg.prefix.length).trim().split(/ +/);
|
||||||
const command: string = args.shift()!.toLowerCase();
|
const command: string = args.shift()!.toLowerCase();
|
||||||
|
|
||||||
if (!client.commands.has(command)) return;
|
if (!client.commands.has(command)) return;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
client.commands.get(command).execute(msg, args);
|
||||||
client.commands.get(command).execute(msg, args);
|
}
|
||||||
}
|
catch (error) {
|
||||||
catch (error)
|
console.error(error);
|
||||||
{
|
msg.reply('There was an error...');
|
||||||
console.error(error);
|
}
|
||||||
msg.reply('There was an error...');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client.on("ready", onReady);
|
client.on("ready", onReady);
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
{
|
{
|
||||||
"compilerOptions":
|
"compilerOptions": {
|
||||||
{
|
"target": "es2020",
|
||||||
"target": "es2020",
|
"module": "commonjs",
|
||||||
"module": "commonjs",
|
"outDir": "build/",
|
||||||
"outDir": "build/",
|
"esModuleInterop": true,
|
||||||
"esModuleInterop": true,
|
"strict": true
|
||||||
"strict": true
|
|
||||||
},
|
},
|
||||||
|
"include": [
|
||||||
"include":
|
"src/**/*",
|
||||||
[
|
"config.json"
|
||||||
"src/**/*",
|
|
||||||
"config.json"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue