-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
slash.js
30 lines (27 loc) · 962 Bytes
/
slash.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
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord.js');
const { readdirSync } = require('fs');
const path = require('path');
require('colors');
require('dotenv').config();
// setup slash commands
const commands = []
readdirSync("./slash/").map(async dir => {
readdirSync(`./slash/${dir}/`).map(async (cmd) => {
commands.push(require(path.join(__dirname, `./slash/${dir}/${cmd}`)))
})
})
const rest = new REST({ version: "10" }).setToken(process.env.TOKEN);
(async () => {
try {
console.log('[Discord API] Started refreshing application (/) commands.'.yellow);
await rest.put(
// if you want to make your slash commands in all guilds use "applicationCommands("CLIENT_ID")"
Routes.applicationGuildCommands(process.env.BOTID, process.env.SERVERID),
{ body: commands },
);
console.log('[Discord API] Successfully reloaded application (/) commands.'.green);
} catch (error) {
console.error(error);
}
})();