Search code examples
javascriptdiscorddiscord.jscommandslash

Deleting all Slash Commands


how to delete all slash commands using discord.js? I'm using 13.5.0 version

bot.on('interactionCreate', interaction => {
          if (!interaction.isCommand()) return;
          bot.api.applications(bot.user.id).commands(interaction.commandId).delete();
});

I tried to do this, but it's just gives me error: Uncaught DiscordAPIError: Unknown application command


Solution

  • Setting slash commands takes up to an hour if done globally, so use the second param, guildid, to delete the slash commands of your bot for a testing server when testing. remove the second param when you want the slash commands to appear globally.

    The code would be like so:

    bot.application.commands.set([], <GuildId>);