all repos — simple-discord-music-bot @ 150cab4bd1dd3d852b5e00f38fd890fc95923c63

A Discord bot making use of discord.js and play-yt.

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
 6if (!(clientId && guildId && token))
 7	throw 'Check your config.json!';
 8
 9const rest = new REST({ version: '10' }).setToken(token);
10// for guild-based commands
11rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
12	.then(() => console.log('Successfully deleted all guild commands.'))
13	.catch(console.error);
14
15// for global commands
16rest.put(Routes.applicationCommands(clientId), { body: [] })
17	.then(() => console.log('Successfully deleted all application commands.'))
18	.catch(console.error);