-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateSlashCommands.js
More file actions
34 lines (31 loc) · 1.1 KB
/
Copy pathupdateSlashCommands.js
File metadata and controls
34 lines (31 loc) · 1.1 KB
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
require('dotenv').config();
const { Routes } = require('discord-api-types/v9');
const { REST } = require('@discordjs/rest');
const rest = new REST({ version: '9' }).setToken(process.env.BOT_TOKEN);
module.exports = async function(c, b) {
try {
console.log('Slash: looking for changes...')
await rest.get(Routes.applicationGuildCommands(c.user.id, '697161337049972778'))
.then(async (data) => {
if (!data || data.length !== b.length) {
console.log('Slash: changes found! Updating...')
await rest.put(
Routes.applicationGuildCommands(c.user.id, '697161337049972778'), { body: b }
);
console.log('Slash: update finished!')
}
else {
console.log('Slash: no changes has been made!')
}
});
await rest.put(
Routes.applicationCommands(c.user.id), {
body: b
}
);
console.log('Slash: frissítése befejeződött!');
}
catch (error) {
console.error(error);
}
}