File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed
Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change 11import { API } from '@discordjs/core/http-only' ;
2- import { REST , type RESTPutAPIApplicationCommandsResult } from 'discord.js' ;
2+ import {
3+ REST ,
4+ type RESTPutAPIApplicationCommandsResult ,
5+ type RESTPutAPIApplicationGuildCommandsJSONBody ,
6+ } from 'discord.js' ;
37import { commands } from '../commands/index.js' ;
48import { config } from '../env.js' ;
59
610export async function deployCommands ( ) : Promise < RESTPutAPIApplicationCommandsResult > {
711 const commandData = [ ...commands . values ( ) ] . map ( ( command ) => command . data ) ;
812
13+ const guildId = config . discord . serverId ;
14+
915 const rest = new REST ( { version : '10' } ) . setToken ( config . discord . token ) ;
1016 const api = new API ( rest ) ;
1117
12- const result = await api . applicationCommands . bulkOverwriteGlobalCommands (
13- config . discord . clientId ,
14- commandData
15- ) ;
18+ let result : RESTPutAPIApplicationCommandsResult ;
19+
20+ if ( guildId ) {
21+ result = await api . applicationCommands . bulkOverwriteGuildCommands (
22+ config . discord . clientId ,
23+ guildId ,
24+ commandData as RESTPutAPIApplicationGuildCommandsJSONBody
25+ ) ;
26+ } else {
27+ result = await api . applicationCommands . bulkOverwriteGlobalCommands (
28+ config . discord . clientId ,
29+ commandData
30+ ) ;
31+ }
1632
1733 console . log ( `Successfully registered ${ result . length } commands.` ) ;
1834 return result ;
You can’t perform that action at this time.
0 commit comments