-
Notifications
You must be signed in to change notification settings - Fork 1
/
handler.js
49 lines (28 loc) · 1.03 KB
/
handler.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const fs = require("fs");
module.exports = async (client) => {
const SlashsArray = [];
const loadSlashCommands = async () => {
const slashFolders = fs.readdirSync('./commands');
for (const subfolder of slashFolders) {
const slashFiles = fs.readdirSync(`./commands/${subfolder}/`).filter(file => file.endsWith('.js'));
for (const file of slashFiles) {
const command = require(`./commands/${subfolder}/${file}`);
if (!command.name) continue;
client.slashCommands.set(command.name, command);
SlashsArray.push(command);
}
}
};
await loadSlashCommands();
const arrayOfSlashCommands = [];
SlashsArray.map((value) => {
const file = value
if (!file?.name) return;
client.slashCommands.set(file.name, file);
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
arrayOfSlashCommands.push(file);
});
client.on("ready", async () => {
await client.application.commands.set(arrayOfSlashCommands);
});
};