tools/delete-commands.js (view raw)
1const path = require('node:path');
2const { Routes } = require('discord.js');
3const { REST } = require('@discordjs/rest');
4const { clientId, guildId, token } = require(path.join(process.cwd(), 'config.json'));
5
6const rest = new REST({ version: '10' }).setToken(token);
7
8// for guild-based commands
9rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
10 .then(() => console.log('Successfully deleted all guild commands.'))
11 .catch(console.error);
12
13// for global commands
14rest.put(Routes.applicationCommands(clientId), { body: [] })
15 .then(() => console.log('Successfully deleted all application commands.'))
16 .catch(console.error);