Skip to content

Instantly share code, notes, and snippets.

@hmes98318
Last active October 17, 2022 08:32
Show Gist options
  • Save hmes98318/35d5bd984028c18088a0d3e1dcb8b505 to your computer and use it in GitHub Desktop.
Save hmes98318/35d5bd984028c18088a0d3e1dcb8b505 to your computer and use it in GitHub Desktop.
/*
* Description: Discord.js v14 Remove Slash Commands script
* Author: hmes98318
* License: MIT
* node_modules: discord.js
*/
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v10');
const config = {
TOKEN: "your_TOKEN",
CLIENT_ID: "your_CLIENT_ID",
GUILD_ID: "your_GUILD_ID"
}
const removeGlobally = (TOKEN, CLIENT_ID) => {
const rest = new REST({ version: '10' })
.setToken(TOKEN);
rest.get(Routes.applicationCommands(CLIENT_ID))
.then(data => {
const promises = [];
for (const command of data) {
const deleteUrl = `${Routes.applicationCommands(CLIENT_ID)}/${command.id}`;
console.log(deleteUrl)
promises.push(rest.delete(deleteUrl));
}
return Promise.all(promises);
});
}
const removeGuild = (TOKEN, CLIENT_ID, GUILD_ID) => {
const rest = new REST({ version: '10' })
.setToken(TOKEN);
rest.get(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID))
.then(data => {
const promises = [];
for (const command of data) {
const deleteUrl = `${Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID)}/${command.id}`;
console.log(deleteUrl)
promises.push(rest.delete(deleteUrl));
}
return Promise.all(promises);
});
}
// remove single guild slash commands
removeGuild(config.TOKEN, config.CLIENT_ID, config.GUILD_ID);
// remove all guild slash commands
//removeGlobally(config.TOKEN, config.CLIENT_ID);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment