From 1eb93ec5c06e3d029c4c353f84f4af7d1dac88c6 Mon Sep 17 00:00:00 2001 From: hackermon Date: Mon, 1 May 2023 19:31:59 -0400 Subject: [PATCH] add remote command script --- remove-commands.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 remove-commands.js diff --git a/remove-commands.js b/remove-commands.js new file mode 100644 index 0000000..82e36fb --- /dev/null +++ b/remove-commands.js @@ -0,0 +1,27 @@ +const { createInterface } = require('node:readline'); +const { Client, Routes } = require('discord.js'); +const commandNames = ['ping', 'command2', 'command3', 'command4']; + +const client = new Client({ intents: [] }); +const rl = createInterface({ input: process.stdin, output: process.stdout }); + +const question = (q) => new Promise((resolve) => rl.question(q, resolve)); +(async ()=>{ + const token = await question('Application token? '); + + await client.login(token); + const commands = await client.rest.get(Routes.applicationCommands(client.user.id)); + + const toBeRemoved = commands.filter((c) => commandNames.includes(c.name)); + + console.log('removing', toBeRemoved); + for (let i = 0; i < toBeRemoved.length; i++) { + const command = toBeRemoved[i]; + await client.rest.delete(`/applications/${client.user.id}/commands/${command.id}`); + + console.log('removed', command.id, command.name); + }; + + console.log('done'); + process.exit(); +})();