-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdeployCommands.js
More file actions
36 lines (32 loc) · 910 Bytes
/
deployCommands.js
File metadata and controls
36 lines (32 loc) · 910 Bytes
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
import fs from "fs";
import { config } from "dotenv";
import { REST } from "@discordjs/rest";
import { Routes } from "discord-api-types/v9";
config();
const gatherCommands = async () => {
const commands = [];
const commandFiles = fs
.readdirSync("./commands")
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const command = await import(`./commands/${file}`);
commands.push(command.default.builder.toJSON());
}
return commands;
};
(async () => {
const commands = await gatherCommands();
const rest = new REST({ version: "9" }).setToken(process.env.TOKEN);
try {
await rest.put(
Routes.applicationGuildCommands(
process.env.CLIENT_ID,
process.env.GUILD_ID,
),
{ body: commands },
);
console.log("Successfully registered application commands.");
} catch (error) {
console.error(error);
}
})();