File tree 3 files changed +5
-7
lines changed 3 files changed +5
-7
lines changed Original file line number Diff line number Diff line change 1
- import type { BotModule } from '../types/bot' ;
1
+ import type { BotCommand } from '../types/bot' ;
2
2
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 ) ;
7
5
const uniqueSlashCommandNames = new Set ( slashCommandNames ) ;
8
6
if ( uniqueSlashCommandNames . size !== slashCommandNames . length ) {
9
7
throw new Error ( 'Found duplicate slash command names' ) ;
Original file line number Diff line number Diff line change @@ -10,8 +10,7 @@ export const loadModules = async (
10
10
modulesToLoad : Record < string , BotModule > ,
11
11
) : Promise < void > => {
12
12
const botCommands = Object . values ( modulesToLoad ) . flatMap ( ( module ) => module . slashCommands ?? [ ] ) ;
13
-
14
- checkUniqueSlashCommandNames ( modulesToLoad ) ;
13
+ checkUniqueSlashCommandNames ( botCommands ) ;
15
14
routeCommands ( client , botCommands ) ;
16
15
await pushCommands ( botCommands . map ( ( command ) => command . schema ) ) ;
17
16
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const client = new Client({
12
12
await client . login ( discord . token ) ;
13
13
await new Promise < void > ( ( resolve ) => {
14
14
client . on ( 'ready' , ( ) => {
15
+ Object . values ( modules ) . map ( ( module ) => module . eventHandlers ?. ready ?.( client ) ) ;
15
16
resolve ( ) ;
16
17
} ) ;
17
18
} ) ;
You can’t perform that action at this time.
0 commit comments