-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy-commands.js
More file actions
45 lines (27 loc) · 1.04 KB
/
deploy-commands.js
File metadata and controls
45 lines (27 loc) · 1.04 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
35
36
37
38
39
40
41
42
43
44
45
const { REST, Routes, SlashCommandBuilder } = require('discord.js');
const { clientId, token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');
const faqPath = path.join(__dirname, 'faq.json');
const faqData = JSON.parse(fs.readFileSync(faqPath, 'utf8'));
const faqChoices = faqData.map(item => ({
name: item.topic.replace(/_/g, ' '),
value: item.topic
}));
const commands = [];
const rest = new REST({ version: '10' }).setToken(token);
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
if (!clientId) {
throw new Error('clientId is missing in config.json. Please add it.');
}
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
console.error(error);
}
})();