@@ -10,7 +10,7 @@ export const info = {
1010 command : "reload" ,
1111 description : "Reload a specific command or all commands." ,
1212 usage : "reload [command]" ,
13- example : "reload poli " ,
13+ example : "reload ai " ,
1414 role : "admin" ,
1515 cooldown : 5000 ,
1616} ;
@@ -36,39 +36,53 @@ export default async function (msg: Message) {
3636 }
3737 }
3838
39- if ( ! found ) await msg . reply ( `Failed to reload command "${ query } ".` ) ;
40- if ( found ) await msg . reply ( `Reloaded command "${ query } ".` ) ;
39+ if ( ! found )
40+ await msg . reply (
41+ `
42+ \`Failed to load\`
43+ ${ query }
44+ `
45+ ) ;
46+ if ( found )
47+ await msg . reply (
48+ `
49+ \`Successfully reloaded\`
50+ ${ query }
51+ `
52+ ) ;
4153 return ;
4254 }
4355
4456 // Reload all commands
4557 let count = 0 ;
58+ const newCommands : string [ ] = [ ] ;
59+ const removeCommands : string [ ] = [ ] ;
4660 const commandsPath = path . join ( __dirname , ".." , "commands" ) ;
61+
4762 fs . readdirSync ( commandsPath ) . forEach ( ( file ) => {
4863 if ( / \. j s $ | \. t s $ / . test ( file ) ) {
49- const filePath = path . join ( commandsPath , file ) ;
50- delete require . cache [ require . resolve ( filePath ) ] ;
51- const commandModule = require ( filePath ) ;
52-
53- if (
54- typeof commandModule . default === "function" &&
55- commandModule . info &&
56- commandModule . info . command
57- ) {
58- commands [ commandModule . info . command ] = {
59- command : commandModule . info . command ,
60- description : commandModule . info . description || "No description" ,
61- usage : commandModule . info . usage || "No usage" ,
62- example : commandModule . info . example || "No example" ,
63- role : commandModule . info . user || "user" ,
64- cooldown : commandModule . info . cooldown || 5000 ,
65- exec : commandModule . default ,
66- } ;
67- count ++ ;
68- log . info ( "Loader" , `Reloaded command: ${ commandModule . info . command } ` ) ;
64+ const commandName = file . replace ( / \. ( j s | t s ) $ / , "" ) ;
65+ if ( ! commands [ commandName ] ) {
66+ newCommands . push ( commandName ) ;
67+ } else {
68+ removeCommands . push ( commandName ) ;
6969 }
70+ Loader ( file ) ;
71+ count ++ ;
7072 }
7173 } ) ;
7274
73- await msg . reply ( `Reloaded ${ count } commands.` ) ;
75+ let text = `
76+ \`Reloaded\`
77+ ${ count } commands
78+ ` ;
79+
80+ if ( newCommands . length > 0 ) {
81+ text += `
82+ \`Found new command(s)\`
83+ ${ newCommands . join ( ", " ) }
84+ ` ;
85+ }
86+
87+ await msg . reply ( text ) ;
7488}
0 commit comments