11import debug from "debug" ;
2- import { ApplicationCommand , Collection } from "discord.js" ;
3- import { existsSync , lstatSync } from "node:fs" ;
4- import { readdir } from "node:fs/promises" ;
2+ import { Collection } from "discord.js" ;
3+ import { existsSync } from "node:fs" ;
4+ import { lstat , readdir } from "node:fs/promises" ;
55import { basename , resolve } from "node:path" ;
66
77import DiscordCommand from "./DiscordCommand" ;
@@ -14,7 +14,8 @@ import type {
1414 Interaction ,
1515 CacheType ,
1616 UserApplicationCommandData ,
17- ChatInputApplicationCommandData
17+ ChatInputApplicationCommandData ,
18+ ApplicationCommand
1819} from "discord.js" ;
1920
2021export interface ModuleLoaderOptions {
@@ -56,7 +57,7 @@ export default class DiscordModuleLoader {
5657
5758 const returnGuilds : [ string , DiscordGuild ] [ ] = [ ] ;
5859 for ( const folder of guilds ) {
59- if ( ! lstatSync ( resolve ( dir , folder ) ) . isDirectory ( ) )
60+ if ( ! ( await lstat ( resolve ( dir , folder ) ) ) . isDirectory ( ) )
6061 throw new Error ( `${ folder } is not a directory.` ) ;
6162
6263 if ( ! existsSync ( resolve ( dir , folder , "index.js" ) ) )
@@ -109,7 +110,7 @@ export default class DiscordModuleLoader {
109110
110111 const returnModules : [ string , DiscordModule ] [ ] = [ ] ;
111112 for ( const folder of modules ) {
112- if ( ! lstatSync ( resolve ( dir , folder ) ) . isDirectory ( ) )
113+ if ( ! ( await lstat ( resolve ( dir , folder ) ) ) . isDirectory ( ) )
113114 throw new Error ( `${ folder } is not a directory.` ) ;
114115
115116 if ( ! existsSync ( resolve ( dir , folder , "index.js" ) ) )
@@ -194,9 +195,7 @@ export default class DiscordModuleLoader {
194195 if ( this . commands . has ( command . name . toLowerCase ( ) ) )
195196 throw new Error ( `Cannot add ${ command . name } more than once.` ) ;
196197
197- if ( globalCommands === true ) command . scope = "GLOBAL" ;
198198 if ( globalCommands !== true ) {
199- command . scope = "GUILD" ;
200199 command . guildId = globalCommands ;
201200 }
202201
@@ -210,7 +209,7 @@ export default class DiscordModuleLoader {
210209 async updateSlashCommands ( ) {
211210 if ( ! this . client . isReady ( ) ) throw new Error ( "Client is not ready." ) ;
212211
213- const localGlobalCommands = this . commands . filter ( c => c . scope === "GLOBAL" ) ,
212+ const localGlobalCommands = this . commands . filter ( c => ! c . guildId ) ,
214213 log = this . log . extend ( "SlashCommands" ) ;
215214
216215 log ( "Setting %d global commands..." , localGlobalCommands . size ) ;
0 commit comments