-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
44 lines (33 loc) · 950 Bytes
/
deploy.js
File metadata and controls
44 lines (33 loc) · 950 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
37
38
39
40
41
42
43
44
const { REST, Routes } = require("discord.js");
const fs = require("fs");
const path = require("path");
const config = require("./config");
function getFiles(dir) {
let files = [];
for (const item of fs.readdirSync(dir)) {
const fullPath = path.join(dir, item);
if (fs.statSync(fullPath).isDirectory()) {
files = files.concat(getFiles(fullPath));
} else if (item.endsWith(".js")) {
files.push(fullPath);
}
}
return files;
}
(async () => {
const commands = [];
const slashPath = path.join(__dirname, "src/slashCommands");
const slashFiles = getFiles(slashPath);
for (const file of slashFiles) {
const cmd = require(file);
if (cmd.data) {
commands.push(cmd.data.toJSON());
}
}
const rest = new REST({ version: "10" }).setToken(config.token);
await rest.put(
Routes.applicationCommands(config.clientId),
{ body: commands }
);
console.log(commands.length);
})();