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