-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetcommands.js
More file actions
29 lines (28 loc) · 813 Bytes
/
Copy pathsetcommands.js
File metadata and controls
29 lines (28 loc) · 813 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
const { REST, Routes, body } = require("discord.js");
const fs = require("fs");
const path = require("path");
require("dotenv").config();
console.log("searching for commands");
const commandsPath = path.join(__dirname, "commands");
const allCommands = fs
.readdirSync(commandsPath)
.filter((c) => c.endsWith(".js"));
const commands = [];
for (const file of allCommands) {
const command = require(`./commands/${file}`);
if ("data" in command) {
commands.push(command.data.toJSON());
}
}
console.log("requesting the api");
const rest = new REST({ version: "10" }).setToken(process.env.token);
(async () => {
try {
await rest.put(Routes.applicationCommands(process.env.id), {
body: commands,
});
console.log("commands set");
} catch (error) {
console.error(error);
}
})();