@@ -73,22 +73,6 @@ export class CommandHelper {
7373 }
7474 }
7575
76- // Load userInstall commands
77- if ( fs . existsSync ( commandDirs . userInstall ) ) {
78- const userCommandFiles = getFilesRecursively ( commandDirs . userInstall , [ ".js" ] ) ;
79- for ( const filePath of userCommandFiles ) {
80- try {
81- const module = await import ( pathToFileURL ( filePath ) . href ) ;
82- if ( module . default ?. data ) {
83- cmdlist . push ( module . default . data . toJSON ( ) ) ;
84- stats . userInstall ++ ;
85- }
86- } catch ( error ) {
87- console . error ( `Failed to load userInstall command from ${ filePath } :` . red , error ) ;
88- }
89- }
90- }
91-
9276 // Load context menu commands
9377 if ( fs . existsSync ( commandDirs . contextMenus ) ) {
9478 const contextCommandFiles = getFilesRecursively ( commandDirs . contextMenus , [ ".js" ] ) ;
@@ -123,8 +107,7 @@ export class CommandHelper {
123107
124108 const restClient = new REST ( { version : "10" } ) . setToken ( Config . Bot . DiscordBotToken ) ;
125109
126-
127-
110+
128111 // Clear application command
129112 await restClient . put ( Routes . applicationCommands ( Config . Bot . DiscordApplicationId ) , {
130113 body : [ ] ,
@@ -134,7 +117,7 @@ export class CommandHelper {
134117 await restClient . put ( Routes . applicationGuildCommands ( Config . Bot . DiscordApplicationId , guild . id ) , {
135118 body : [ ] ,
136119 } ) ;
137-
120+
138121 const buildInCommandOverrides = await database . buildInCommands . findMany ( {
139122 where : {
140123 GuildCommandMangerId : guild . id
@@ -232,6 +215,7 @@ export class CommandHelper {
232215
233216 public static async loadCommands ( client : ExtendedClient ) {
234217 let cmdlist : any [ ] = [ ] ;
218+ let applicationcmdlist : any [ ] = [ ] ;
235219 const stats = {
236220 commands : 0 ,
237221 userInstall : 0 ,
@@ -294,7 +278,7 @@ export class CommandHelper {
294278 try {
295279 const module = await import ( pathToFileURL ( filePath ) . href ) ;
296280 if ( module . default ?. data ) {
297- cmdlist . push ( module . default . data . toJSON ( ) ) ;
281+ applicationcmdlist . push ( module . default . data . toJSON ( ) ) ;
298282 stats . userInstall ++ ;
299283 }
300284 } catch ( error ) {
@@ -342,14 +326,18 @@ export class CommandHelper {
342326 body : [ ] ,
343327 } ) ;
344328
345- const allGuilds = await client . guilds . fetch ( ) ;
346- for ( const guild of allGuilds . values ( ) ) {
329+ await restClient . put ( Routes . applicationCommands ( Config . Bot . DiscordApplicationId ) , {
330+ body : applicationcmdlist ,
331+ } ) ;
347332
333+ Logger . info ( "Application Command Loaded" )
334+ Logger . info ( `Loading guild commands for ${ client . guilds . cache . size } guilds...` )
335+ client . guilds . cache . forEach ( async ( guild ) => {
348336 // Clear Guild Commands
349337 await restClient . put ( Routes . applicationGuildCommands ( Config . Bot . DiscordApplicationId , guild . id ) , {
350338 body : [ ] ,
351339 } ) ;
352-
340+
353341 const buildInCommandOverrides = await database . buildInCommands . findMany ( {
354342 where : {
355343 GuildCommandMangerId : guild . id
@@ -444,6 +432,6 @@ export class CommandHelper {
444432 botType : Config . BotType . toString ( ) || "Unknown" ,
445433 action : LoggingAction . Command ,
446434 } ) ;
447- }
435+ } )
448436 }
449437}
0 commit comments