Skip to content

Commit

Permalink
feat: Use data.module to define type
Browse files Browse the repository at this point in the history
The DiscordBot class now uses the data.module property to define if the bot module is a command or an event or other
  • Loading branch information
The Alpha committed Sep 30, 2023
1 parent 0735c50 commit 4d102b1
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/core/discordBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 4d102b1

Please sign in to comment.