diff --git a/package.json b/package.json index 2744dfe..445e146 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "muffin-ai-arujak", - "version": "2.0.0-81-oreo", + "version": "2.0.0-82-oreo", "main": "dist/index.js", "private": true, "dependencies": { diff --git a/src/Client.ts b/src/Client.ts index d04b30e..0f13722 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -57,24 +57,32 @@ export default class MuffinAI extends Client { console.log(`먹힐 준비 완료`) }).on('messageCreate', async msg => { + const args: string[] = msg.content + .slice(prefix.length) + .trim() + .split(/ +/g) + + if (NODE_ENV === 'development') console.log(args) if (msg.author.bot) return if (msg.content.startsWith('머핀아 ')) { if (msg.channel instanceof TextChannel) { await msg.channel.sendTyping() - this.chatBot // - .getResponse(msg) - .then(response => { - msg.channel.send(response) - }) + const command = this.#modules.get(args.shift()!.toLowerCase()) + + if (command) { + if (command.noPerm && msg.author.id !== config.bot.owner_ID) + return await noPerm(msg) + + command.execute(msg, args) + } else { + const response = await this.chatBot.getResponse(msg) + await msg.channel.send(response) + } } } else if (msg.content.startsWith(prefix)) { if (msg.channel instanceof TextChannel) if (msg.channel.nsfw) return + await msg.channel.sendTyping() - const args: string[] = msg.content - .slice(prefix.length) - .trim() - .split(/ +/g) - if (NODE_ENV === 'development') console.log(args) const command = this.#modules.get(args.shift()!.toLowerCase()) if (!command) return if (command.noPerm && msg.author.id !== config.bot.owner_ID)