Skip to content

Commit d9cb95a

Browse files
Merge branch 'master' into feat/quoi-feur
2 parents 6b7d6b0 + 9221e88 commit d9cb95a

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/core/checkUniqueSlashCommandNames.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import type { BotModule } from '../types/bot';
1+
import type { BotCommand } from '../types/bot';
22

3-
export const checkUniqueSlashCommandNames = (modulesToLoad: Record<string, BotModule>) => {
4-
const slashCommandNames = Object.values(modulesToLoad)
5-
.flatMap((module) => module.slashCommands ?? [])
6-
.map((command) => command.schema.name);
3+
export const checkUniqueSlashCommandNames = (botCommands: BotCommand[]) => {
4+
const slashCommandNames = botCommands.map((command) => command.schema.name);
75
const uniqueSlashCommandNames = new Set(slashCommandNames);
86
if (uniqueSlashCommandNames.size !== slashCommandNames.length) {
97
throw new Error('Found duplicate slash command names');

src/core/loadModules.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ export const loadModules = async (
1010
modulesToLoad: Record<string, BotModule>,
1111
): Promise<void> => {
1212
const botCommands = Object.values(modulesToLoad).flatMap((module) => module.slashCommands ?? []);
13-
14-
checkUniqueSlashCommandNames(modulesToLoad);
13+
checkUniqueSlashCommandNames(botCommands);
1514
routeCommands(client, botCommands);
1615
await pushCommands(botCommands.map((command) => command.schema));
1716

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const client = new Client({
1212
await client.login(discord.token);
1313
await new Promise<void>((resolve) => {
1414
client.on('ready', () => {
15+
Object.values(modules).map((module) => module.eventHandlers?.ready?.(client));
1516
resolve();
1617
});
1718
});

0 commit comments

Comments
 (0)