Deleting Commands

Deleting commands is extremely simple. Just add the deleted property to the object that is being exported from your command file, like this:

commands/ping.js
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
  deleted: true, // This will delete your command
  data: new SlashCommandBuilder()
          .setName('ping')
          .setDescription('Pong!'),
          
  run: ({ interaction, client, handler }) => {
    interaction.reply(`Pong! ${client.ws.ping}ms`);
  },
};

Adding the deleted property and setting it to a truthy value will delete the command the next time you take your Discord bot online. This also means if you restart your bot, this command will not be registered again.

If you added a testServer property to your CommandHandler instance, only your guild-based commands will be deleted. If your commands are registered globally, remove testServer then run your application to properly delete your commands globally (Updating/removing global commands can take a while).

Last updated