From 4d102b122ee307527ff7930a201dcaec2f0ab34f Mon Sep 17 00:00:00 2001 From: The Alpha Date: Sat, 30 Sep 2023 12:43:26 +0800 Subject: [PATCH] feat: Use data.module to define type The DiscordBot class now uses the data.module property to define if the bot module is a command or an event or other --- src/core/discordBot.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/core/discordBot.js b/src/core/discordBot.js index f5b084c..dc8e6be 100644 --- a/src/core/discordBot.js +++ b/src/core/discordBot.js @@ -189,20 +189,23 @@ class DiscordBot { for (let i = 0; i < paths.length; i++) { const botModule = require(paths[i]); - if ( - botModule instanceof BotCommand && - BotCommand.isValid(botModule) - ) { - const record = this.registerCommand(botModule); - records[RecordStates.Success].push(record); - continue; - } else if ( - botModule instanceof BotEvent && - BotEvent.isValid(botModule) - ) { - const record = this.registerEvent(botModule); - records[RecordStates.Success].push(record); - continue; + + if (botModule.data && botModule.data.module) { + if ( + botModule.data.module === "command" && + BotCommand.isValid(botModule) + ) { + const record = this.registerCommand(botModule); + records[RecordStates.Success].push(record); + continue; + } else if ( + botModule.data.module === "event" && + BotEvent.isValid(botModule) + ) { + const record = this.registerEvent(botModule); + records[RecordStates.Success].push(record); + continue; + } } const word = "modules";