@@ -35,15 +35,12 @@ const client = new Client({ intents: [Intents.FLAGS.GUILDS] })
35
35
const commands = new Collection < string , Command > ( )
36
36
37
37
const commandFiles = fs . readdirSync ( path . join ( __dirname , 'commands' ) ) . filter ( file => file . endsWith ( '.ts' ) )
38
- const dataArr = [ ]
39
38
40
39
const clientId = process . env . NODE_ENV === 'production' ? settings . prodId : settings . devId
41
- const guildId = '423525617598988288'
42
40
43
41
for ( const file of commandFiles ) {
44
42
const command : Command = require ( `./commands/${ file } ` )
45
43
commands . set ( command . data . name , command )
46
- dataArr . push ( command . data )
47
44
}
48
45
49
46
const rest = new REST ( { version : '9' } ) . setToken ( process . env . TOKEN ) ;
@@ -54,9 +51,9 @@ const rest = new REST({ version: '9' }).setToken(process.env.TOKEN);
54
51
55
52
await rest . put (
56
53
process . env . NODE_ENV === 'development'
57
- ? Routes . applicationGuildCommands ( clientId , guildId ) // register commands as guild commands in development (instantly updates)
54
+ ? Routes . applicationGuildCommands ( clientId , settings . guildId ) // register commands as guild commands in development (instantly updates)
58
55
: Routes . applicationCommands ( clientId ) , // otherwise, register commands globally (updates slower, up to an hour)
59
- { body : dataArr }
56
+ { body : commands . map ( command => command . data ) }
60
57
)
61
58
62
59
console . log ( 'Successfully reloaded application (/) commands.' )
@@ -66,15 +63,12 @@ const rest = new REST({ version: '9' }).setToken(process.env.TOKEN);
66
63
} ) ( )
67
64
68
65
// Client events
69
- client . once ( 'ready' , ( ) => {
70
- console . log ( 'Ready!' )
71
- } )
66
+ client . once ( 'ready' , ( ) => { console . log ( 'Ready!' ) } )
72
67
73
68
client . on ( 'interactionCreate' , async interaction => {
74
69
if ( ! interaction . isCommand ( ) ) return
75
70
76
71
const command = commands . get ( interaction . commandName )
77
-
78
72
if ( ! command ) return
79
73
80
74
try {
0 commit comments