-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_commands.js
39 lines (32 loc) · 1.03 KB
/
deploy_commands.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
const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v10");
const { readCommands } = require("./utils/files");
const env = require("dotenv");
env.config();
const slashCommands = [];
const rest = new REST({ version: "10" }).setToken(process.env.BOT_TOKEN);
// and deploy your commands!
const files = readCommands("./commands", {
justSlashCommands: true,
});
for (const command of files) {
slashCommands.push(command.props.data.toJSON());
}
(async () => {
try {
console.log(
`Started refreshing ${slashCommands.length} application (/) commands.`
);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationCommands(process.env.BOT_CLIENT_ID),
{ body: slashCommands }
);
console.log(
`Successfully reloaded ${data.length} application (/) commands.`
);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();