Delete all Slash Commands

I'm trying to figure out if theres a way, as quite literally. they dont sync
6 Replies
d.js toolkit
d.js toolkit6mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Osintedx
OsintedxOP6mo ago
Anyone have an idea?
d.js docs
d.js docs6mo ago
If you have duplicate commands on your server, you registered both global and guild commands. You can remove the duplicates by resetting either the global or guild commands - Resetting global commands: rest.put(Routes.applicationCommands(clientId), { body: [] }) - Resetting guild commands: rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
Osintedx
OsintedxOP6mo ago
I just throw that in my deploy-commands? ReferenceError: Cannot access 'commands' before initialization :Bruh: that's weird, I swear I put them. Yeah, i did. I just made this.
const { REST, Routes, SlashCommandBuilder } = require('discord.js');
const { clientId, guildId, token } = require('./config.json');

module.exports = {
data: new SlashCommandBuilder()
.setName('delete-commands')
.setDescription('Delete all slash commands'),
async execute(interaction) {
const rest = new REST().setToken(token);

try {
await rest.get(Routes.applicationGuildCommands(clientId, guildId));
const commands = await rest.get(Routes.applicationGuildCommands(clientId, guildId));

if (commands.length === 0) {
await interaction.reply('No commands to delete!');
return;
}

await Promise.all(commands.map(command => rest.delete(`${Routes.applicationGuildCommands(clientId, guildId)}/${command.id}`)));
await interaction.reply(`Deleted ${commands.length} slash commands!`);
} catch (error) {
console.error(error);
await interaction.reply('Error deleting commands!');
}
},
};
const { REST, Routes, SlashCommandBuilder } = require('discord.js');
const { clientId, guildId, token } = require('./config.json');

module.exports = {
data: new SlashCommandBuilder()
.setName('delete-commands')
.setDescription('Delete all slash commands'),
async execute(interaction) {
const rest = new REST().setToken(token);

try {
await rest.get(Routes.applicationGuildCommands(clientId, guildId));
const commands = await rest.get(Routes.applicationGuildCommands(clientId, guildId));

if (commands.length === 0) {
await interaction.reply('No commands to delete!');
return;
}

await Promise.all(commands.map(command => rest.delete(`${Routes.applicationGuildCommands(clientId, guildId)}/${command.id}`)));
await interaction.reply(`Deleted ${commands.length} slash commands!`);
} catch (error) {
console.error(error);
await interaction.reply('Error deleting commands!');
}
},
};
I think it worked. lemme check
Osintedx
OsintedxOP6mo ago
yeah nevermind
No description
Osintedx
OsintedxOP6mo ago
I already figured it out. I don't think I needed a rude ass opinion, but thank you. Considering I haven't touched js in 2+ years, I don't think I needed you to go ahead and disrespect and act like youre entitled. Especially, when I'm asking for assistance on a simple issue. Alright, now you're really sound off. You're claiming I "lied" to you. When I have no clue who you are, nor do I care to. I'm asking for a simple answer. But thank you for an opinion I did not request, I do hope you recieve some type of help for your attitude. Have a good one.
Want results from more Discord servers?
Add your server