@filiberto
To delete a slash command from a discord.js client, you can use the Client#application.commands.delete() method. Here's an example code snippet that demonstrates how to delete a slash command:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILD_MESSAGES] });
const appId = 'YOUR_APPLICATION_ID'; // add your application ID here
const guildId = 'YOUR_GUILD_ID'; // add your guild ID here
client.once('ready', async () => {
const commands = await client.application.commands.fetch(guildId);
const commandId = 'COMMAND_ID_TO_DELETE'; // add the ID of the command you want to delete here
try {
await client.application.commands.delete(commandId, guildId);
console.log('Command deleted successfully!');
} catch (error) {
console.error(error);
}
});
client.login('YOUR_BOT_TOKEN'); // add your bot token here
|
Replace 'YOUR_APPLICATION_ID', 'YOUR_GUILD_ID', and 'COMMAND_ID_TO_DELETE' with the appropriate values for your setup. Keep in mind that you should have the necessary permissions to delete slash commands in the guild.