From 314c744527ca4c6a5f619dce824c69435529e89f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Fri, 3 Sep 2021 02:45:42 +0300 Subject: [PATCH] Remove slash commands when ending process in Dev bot --- src/client/events/SIGINT.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/client/events/SIGINT.js b/src/client/events/SIGINT.js index dc0bf65..e7cbdbf 100644 --- a/src/client/events/SIGINT.js +++ b/src/client/events/SIGINT.js @@ -1,4 +1,7 @@ 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 = { name: 'SIGINT', @@ -33,6 +36,26 @@ module.exports = { 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(() => { if(radio.done){ process.exit();