-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslash.js
27 lines (25 loc) · 855 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
require("dotenv").config();
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { readdirSync } = require('fs');
const path = require('path');
const config = require("./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(
Routes.applicationCommands(config.botID),
{ body: commands },
);
console.log('[Discord API] Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();