-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-commands.js
More file actions
38 lines (32 loc) · 1.18 KB
/
deploy-commands.js
File metadata and controls
38 lines (32 loc) · 1.18 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
const {REST, Routes} = require("discord.js");
const {clientId, guildId, token} = require("./config.json");
const fs = require("node:fs");
const path = require("node:path");
const commands = [];
const foldersPath = path.join(__dirname, 'commands');
const cmdFolders = fs.readdirSync(foldersPath);
for(const folder of cmdFolders){
const cmdPath = path.join(foldersPath, folder);
const cmdFiles = fs.readdirSync(cmdPath);
for(const file of cmdFiles){
const filePath = path.join(cmdPath,file);
const command = require(filePath);
if('data' in command && 'execute' in command){
commands.push(command.data.toJSON());
}else{
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
const rest = new REST().setToken(token);
(async () =>{
try{
console.log(`Started refreshing ${commands.length} slash commands.`);
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),{body:commands}
);
console.log(`Reloading ${data.length} commands was a success.`);
}catch(err){
console.log(err);
}
})();