generated from FnrDev/fnr-template
-
Notifications
You must be signed in to change notification settings - Fork 8
/
slash.js
29 lines (27 loc) · 1.02 KB
/
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
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const path = require('path');
require('colors')
require('dotenv').config();
const { readdirSync } = require('fs')
const commands = []
readdirSync("./commands/").map(async dir => {
readdirSync(`./commands/${dir}/`).map(async (cmd) => {
commands.push(require(path.join(__dirname, `./commands/${dir}/${cmd}`)))
})
})
const rest = new REST({ version: "9" }).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);
console.log(`[Discord API] Successfully reloaded "${commands.length}" commands.`.green);
} catch (error) {
console.error(error);
}
})();