This repository was archived by the owner on Jun 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-commands.js
More file actions
66 lines (56 loc) · 1.84 KB
/
Copy pathdeploy-commands.js
File metadata and controls
66 lines (56 loc) · 1.84 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//#region libs
require('dotenv').config();
const fs = require('fs');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
//Trace Module
const {err, wrn, inf, not, dbg} = require('./trace.js');
//#endregion
const commands = [];
const help = {};
const team = {};
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
const destinyCommandFiles = fs.readdirSync('./commands/destiny').filter(file => file.endsWith('.js'));
not(`Command files list: ${commandFiles}`);
//IDs
const clientId = String(process.env.CLIENT_ID);
//Help file
help.Destiny = [];
for (const file of destinyCommandFiles) {
inf('Destiny Commands');
not(`File: ${file}`);
const command = require(`./commands/destiny/${file}`);
inf(`Detected ${command.data.name} command`);
commands.push(command.data.toJSON());
help.Destiny.push([ `/${command.data.name}`, command.data.description]);
}
help.General = [];
for (const file of commandFiles) {
inf('General commands');
not(`File: ${file}`);
const command = require(`./commands/${file}`);
inf(`Detected ${command.data.name} command`);
commands.push(command.data.toJSON());
help.General.push([ `/${command.data.name}`, command.data.description]);
}
fs.writeFile('./data/help.json', JSON.stringify(help, null, 4), (error) => {
if (error) {
err(error);
console.error(error);
throw error;
}
});
const rest = new REST({ version: 9 }).setToken(process.env.DISCORD_TOKEN);
//Guild commands
(async () => {
try {
inf('Started refreshing application (/) commands ...');
await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
inf('Successfully reloeded application (/) commands');
} catch (error) {
err(error);
}
})();