Remove slash commands when ending process in Dev bot

This commit is contained in:
Christer Warén 2021-09-03 02:45:42 +03:00
parent 555b4d14f0
commit 314c744527

View File

@ -1,4 +1,7 @@
import Discord from "discord.js"; import Discord from "discord.js";
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { token, version } = require('../config.js');
module.exports = { module.exports = {
name: 'SIGINT', name: 'SIGINT',
@ -33,6 +36,26 @@ module.exports = {
client.user.setStatus('dnd'); client.user.setStatus('dnd');
const rest = new REST({ version: '9' }).setToken(token);
if(version.includes("-dev")){
await rest.put(
Routes.applicationCommands(client.user.id),
{ body: [] },
);
let guilds = await client.guilds.fetch();
guilds.forEach(async guild => {
try {
await rest.put(
Routes.applicationGuildCommands(client.user.id, guild.id),
{ body: [] },
);
} catch (DiscordAPIError) {
}
});
}
setInterval(() => { setInterval(() => {
if(radio.done){ if(radio.done){
process.exit(); process.exit();