Skip to content

Commit 1eb93ec

Browse files
authored
add remote command script
1 parent fd3c3f9 commit 1eb93ec

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

remove-commands.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { createInterface } = require('node:readline');
2+
const { Client, Routes } = require('discord.js');
3+
const commandNames = ['ping', 'command2', 'command3', 'command4'];
4+
5+
const client = new Client({ intents: [] });
6+
const rl = createInterface({ input: process.stdin, output: process.stdout });
7+
8+
const question = (q) => new Promise((resolve) => rl.question(q, resolve));
9+
(async ()=>{
10+
const token = await question('Application token? ');
11+
12+
await client.login(token);
13+
const commands = await client.rest.get(Routes.applicationCommands(client.user.id));
14+
15+
const toBeRemoved = commands.filter((c) => commandNames.includes(c.name));
16+
17+
console.log('removing', toBeRemoved);
18+
for (let i = 0; i < toBeRemoved.length; i++) {
19+
const command = toBeRemoved[i];
20+
await client.rest.delete(`/applications/${client.user.id}/commands/${command.id}`);
21+
22+
console.log('removed', command.id, command.name);
23+
};
24+
25+
console.log('done');
26+
process.exit();
27+
})();

0 commit comments

Comments
 (0)