-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploycommands.js
67 lines (44 loc) · 1.68 KB
/
deploycommands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const fs = require('node:fs');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const guildId = '519163744711081991'
const clientId = '796316943002894366'
const BotToken = process.env['BotToken']
const commands = [];
const commandFiles = fs.readdirSync('./Commands')
for (const file of commandFiles) {
const command = require(`./Commands/${file}`);
commands.push(command.data.toJSON());
}
/*
const rest = new REST({ version: '9' }).setToken(BotToken);
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
.then(() => console.log('Successfully registered application commands.'))
.catch(console.error);
const rest = new REST({ version: '9' }).setToken(token);
rest.get(Routes.applicationGuildCommands(clientId, guildId))
.then(data => {
const promises = [];
for (const command of data) {
const deleteUrl = `${Routes.applicationGuildCommands(clientId, guildId)}/${command.id}`;
promises.push(rest.delete(deleteUrl));
}
return Promise.all(promises);
});
*/
/* FOR INDEX.JS
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const guildId = '519163744711081991'
const clientId = '796316943002894366'
const commands = [];
for (const file of commandFiles) {
console.log("Thru")
const command = require(`./Commands/${file}`);
commands.push(command.data.toJSON());
}
const rest = new REST({ version: '9' }).setToken(BotToken);
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
.then(() => console.log('Successfully registered application commands.'))
.catch(console.error);
*/