Reputation:
Slash commands work well, no hassle, set with simple code: bot.commands.set(command.name, command)
But I noticed that they are set only when the bot is running and it is added to the Discord server. If the bot is already on the Discord server, and a new command appeared later, then command does not appear in the list. I fix this by a second invitation, but commands in the list start to double, as if they were cloning yourself. Can this be fixable?
Upvotes: 2
Views: 4016
Reputation: 320
You can remove slash commands either from global commands or server commands. Fetching the commands then logging or using another method to show you the command id will allow you to use the delete method.
You can remove slash commands by using bot.application.commands.delete('id here')
. (global commands) where bot is the DiscordClient or guild commands: guild.commands.delete('id here')
, where guild is the targeted Guild.
These are both functions, and require a command id. You can fetch command ids using: bot.application.commands.fetch().then(c=> console.log(c))
(global cmds), guild.commands.fetch().then(c=>console.log(c))
(server commands)
Upvotes: 1