diff --git a/src/core/checkUniqueSlashCommandNames.ts b/src/core/checkUniqueSlashCommandNames.ts index 189647a..776927c 100644 --- a/src/core/checkUniqueSlashCommandNames.ts +++ b/src/core/checkUniqueSlashCommandNames.ts @@ -1,9 +1,7 @@ -import type { BotModule } from '../types/bot'; +import type { BotCommand } from '../types/bot'; -export const checkUniqueSlashCommandNames = (modulesToLoad: Record) => { - const slashCommandNames = Object.values(modulesToLoad) - .flatMap((module) => module.slashCommands ?? []) - .map((command) => command.schema.name); +export const checkUniqueSlashCommandNames = (botCommands: BotCommand[]) => { + const slashCommandNames = botCommands.map((command) => command.schema.name); const uniqueSlashCommandNames = new Set(slashCommandNames); if (uniqueSlashCommandNames.size !== slashCommandNames.length) { throw new Error('Found duplicate slash command names'); diff --git a/src/core/loadModules.ts b/src/core/loadModules.ts index 0100965..03d1a77 100644 --- a/src/core/loadModules.ts +++ b/src/core/loadModules.ts @@ -10,8 +10,7 @@ export const loadModules = async ( modulesToLoad: Record, ): Promise => { const botCommands = Object.values(modulesToLoad).flatMap((module) => module.slashCommands ?? []); - - checkUniqueSlashCommandNames(modulesToLoad); + checkUniqueSlashCommandNames(botCommands); routeCommands(client, botCommands); await pushCommands(botCommands.map((command) => command.schema)); diff --git a/src/main.ts b/src/main.ts index a9eb77d..c0a4e63 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,6 +12,7 @@ const client = new Client({ await client.login(discord.token); await new Promise((resolve) => { client.on('ready', () => { + Object.values(modules).map((module) => module.eventHandlers?.ready?.(client)); resolve(); }); });