@@ -54,6 +54,10 @@ interface DiscordBotOptions {
5454 * The callback before the bot shut down.
5555 */
5656 onShutDown ?: ( args : { logger : Logger ; client : Client } ) => void
57+ /**
58+ * If true the bot will register the slash commands on start. Defaults to true.
59+ */
60+ registerCommandsOnStart ?: boolean
5761}
5862
5963export class DiscordBot {
@@ -66,6 +70,10 @@ export class DiscordBot {
6670 private readonly slashCommandCollection = new Collection < string , SlashCommand > ( )
6771
6872 constructor ( private readonly options : DiscordBotOptions ) {
73+ if ( options . registerCommandsOnStart === undefined ) {
74+ options . registerCommandsOnStart = true
75+ }
76+
6977 this . logger = createLogger ( 'bot' , this . options . loggerOptions )
7078 this . rest = new REST ( { version : '10' , timeout : 2000 } ) . setToken ( options . token )
7179 const intents = options . intents . reduce ( ( acc , cur ) => acc | cur , 0 )
@@ -181,7 +189,9 @@ export class DiscordBot {
181189 async listen ( ) {
182190 this . setupGracefulShutdown ( )
183191 this . subscribeGatewayDispatchEvents ( )
184- await this . registerSlashCommands ( )
192+ if ( this . options . registerCommandsOnStart ) {
193+ await this . registerSlashCommands ( )
194+ }
185195 this . logger . info ( "Bot's logging in..." )
186196 await this . client . login ( this . options . token )
187197 this . logger . info ( "Bot's ready!" )
0 commit comments