@@ -2,23 +2,22 @@ import { readdirSync } from 'fs';
22import chalk from 'chalk' ;
33
44async function loadSlashCommands ( client ) {
5- const slashCommands = readdirSync ( './src/interactions/commands' ) . filter ( file => file . endsWith ( '.js' ) ) ;
6- for ( let i = 0 ; i < slashCommands . length ; i ++ ) {
7- const command = await import ( `../interactions/commands/${ slashCommands [ i ] } ` ) ;
8- client . slashCommands . set ( command . default . data . toJSON ( ) . name , command . default ) ;
9- console . log ( chalk . greenBright ( `[SLASHCOMMAND] Loaded ${ chalk . yellow ( slashCommands [ i ] ) } with command ${ chalk . yellow ( command . default . data . toJSON ( ) . name ) } ` ) ) ;
10- }
11- }
12-
13- async function reloadSlashCommands ( client ) {
145 client . slashCommands . clear ( ) ;
15- const slashCommands = readdirSync ( './src/interactions/commands ' ) . filter ( file => file . endsWith ( '.js' ) ) ;
6+ const slashCommands = readdirSync ( './src/interactions/slashCommands ' ) . filter ( file => file . endsWith ( '.js' ) ) ;
167 for ( let i = 0 ; i < slashCommands . length ; i ++ ) {
17- const command = await import ( `../interactions/commands/${ slashCommands [ i ] } ?${ Date . now ( ) } ` ) ;
18- client . slashCommands . set ( command . default . data . toJSON ( ) . name , command . default ) ;
19- console . log ( chalk . greenBright ( `[SLASHCOMMAND] Reloaded ${ chalk . yellow ( slashCommands [ i ] ) } with command ${ chalk . yellow ( command . default . data . toJSON ( ) . name ) } ` ) ) ;
8+ const commands = await import ( `../interactions/slashCommands/${ slashCommands [ i ] } ?${ Date . now ( ) } ` ) ;
9+ client . slashCommands . set ( commands . default . data . toJSON ( ) . name , commands . default ) ;
10+ console . log ( chalk . greenBright ( `[SLASHCOMMAND] Loaded ${ chalk . yellow ( slashCommands [ i ] ) } with command ${ chalk . yellow ( commands . default . data . toJSON ( ) . name ) } ` ) ) ;
11+ }
12+ const slashCommandFolders = readdirSync ( './src/interactions/slashCommands' , { withFileTypes : true } ) . filter ( file => file . isDirectory ( ) ) ;
13+ for ( let i = 0 ; i < slashCommandFolders . length ; i ++ ) {
14+ const slashCommands = readdirSync ( `./src/interactions/slashCommands/${ slashCommandFolders [ i ] . name } ` ) . filter ( file => file . endsWith ( '.js' ) ) ;
15+ for ( let j = 0 ; j < slashCommands . length ; j ++ ) {
16+ const commands = await import ( `../interactions/slashCommands/${ slashCommandFolders [ i ] . name } /${ slashCommands [ j ] } ` ) ;
17+ client . slashCommands . set ( commands . default . data . toJSON ( ) . name , commands . default ) ;
18+ console . log ( chalk . greenBright ( `[SLASHCOMMAND] Loaded ${ chalk . yellow ( slashCommands [ j ] ) } with command ${ chalk . yellow ( commands . default . data . toJSON ( ) . name ) } ` ) ) ;
19+ }
2020 }
21- return slashCommands . length ;
2221}
2322
24- export default { loadSlashCommands, reloadSlashCommands } ;
23+ export default { loadSlashCommands } ;
0 commit comments