diff --git a/.changeset/three-berries-impress.md b/.changeset/three-berries-impress.md new file mode 100644 index 0000000..15e57fa --- /dev/null +++ b/.changeset/three-berries-impress.md @@ -0,0 +1,5 @@ +--- +"@softnetics/what-is-dis": minor +--- + +Add reregister command to bot diff --git a/packages/what-is-dis/src/bot/index.ts b/packages/what-is-dis/src/bot/index.ts index 0ca8667..2cf31e2 100644 --- a/packages/what-is-dis/src/bot/index.ts +++ b/packages/what-is-dis/src/bot/index.ts @@ -54,6 +54,10 @@ interface DiscordBotOptions { * The callback before the bot shut down. */ onShutDown?: (args: { logger: Logger; client: Client }) => void + /** + * If true the bot will register the slash commands on start. Defaults to true. + */ + registerCommandsOnStart?: boolean } export class DiscordBot { @@ -66,6 +70,10 @@ export class DiscordBot { private readonly slashCommandCollection = new Collection() constructor(private readonly options: DiscordBotOptions) { + if (options.registerCommandsOnStart === undefined) { + options.registerCommandsOnStart = true + } + this.logger = createLogger('bot', this.options.loggerOptions) this.rest = new REST({ version: '10', timeout: 2000 }).setToken(options.token) const intents = options.intents.reduce((acc, cur) => acc | cur, 0) @@ -181,7 +189,9 @@ export class DiscordBot { async listen() { this.setupGracefulShutdown() this.subscribeGatewayDispatchEvents() - await this.registerSlashCommands() + if (this.options.registerCommandsOnStart) { + await this.registerSlashCommands() + } this.logger.info("Bot's logging in...") await this.client.login(this.options.token) this.logger.info("Bot's ready!")