@@ -4,7 +4,9 @@ import { readdirSync } from 'fs';
44async function loadMessageCommands ( client ) {
55 client . messageCommands . clear ( ) ;
66 client . messageCommandsAliases . clear ( ) ;
7+ let files = 0 ;
78 const commandFiles = readdirSync ( './src/interactions/messageCommands' ) . filter ( file => file . endsWith ( '.js' ) ) ;
9+ if ( ! commandFiles ) return ;
810 for ( let i = 0 ; i < commandFiles . length ; i ++ ) {
911 const command = await import ( `../interactions/messageCommands/${ commandFiles [ i ] } ?${ Date . now ( ) } ` ) ;
1012 if ( command . default . aliases ) {
@@ -14,8 +16,10 @@ async function loadMessageCommands(client) {
1416 }
1517 client . messageCommands . set ( command . default . name , command . default ) ;
1618 console . log ( chalk . greenBright ( `[COMMAND] Loaded ${ ( chalk . yellow ( commandFiles [ i ] ) ) } with command ${ ( chalk . yellow ( command . default . name ) ) } ` ) ) ;
19+ files ++ ;
1720 }
1821 const commandFolders = readdirSync ( './src/interactions/messageCommands' , { withFileTypes : true } ) . filter ( file => file . isDirectory ( ) ) ;
22+ if ( ! commandFolders ) return ;
1923 for ( let i = 0 ; i < commandFolders . length ; i ++ ) {
2024 const commandFiles = readdirSync ( `./src/interactions/messageCommands/${ commandFolders [ i ] . name } ` ) . filter ( file => file . endsWith ( '.js' ) ) ;
2125 for ( let j = 0 ; j < commandFiles . length ; j ++ ) {
@@ -27,8 +31,10 @@ async function loadMessageCommands(client) {
2731 }
2832 client . messageCommands . set ( command . default . name , command . default ) ;
2933 console . log ( chalk . greenBright ( `[COMMAND] Loaded ${ ( chalk . yellow ( commandFiles [ j ] ) ) } with command ${ ( chalk . yellow ( command . default . name ) ) } ` ) ) ;
34+ files ++ ;
3035 }
3136 }
37+ return files ;
3238}
3339
3440export default { loadMessageCommands } ;
0 commit comments