-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslash.js
32 lines (28 loc) · 1.1 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
30
31
32
// This file allows you to register slash commands, it must be launched each time you add a new (/) command
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { readdirSync } = require('fs');
const path = require('path');
require('dotenv').config()
const commands = []
readdirSync("./src/slashCommands/").map(async dir => {
readdirSync(`./src/slashCommands/${dir}/`).map(async (cmd) => {
commands.push(require(path.join(__dirname, `./src/slashCommands/${dir}/${cmd}`)))
})
})
const rest = new REST({ version: "9" }).setToken(process.env.TOKEN);
(async () => {
try {
console.log('[Discord API] Started refreshing application (/) commands.');
await rest.put(
// GUILD SLASH COMMANDS (will deploy only in the server you put the ID of)
// Routes.applicationGuildCommands(config.botID, 'ID_OF_THE_GUILD'),
// GLOBAL SLASH COMMANDS
Routes.applicationCommands(process.env.BOT_ID),
{ body: commands },
);
console.log('[Discord API] Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();