-
Notifications
You must be signed in to change notification settings - Fork 11
/
handler.js
65 lines (59 loc) · 1.9 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const { glob } = require("glob");
const { promisify } = require("util");
const globPromise = promisify(glob);
const WUMPUSBOT = require("./Client");
/**
*
* @param {WUMPUSBOT} client
*/
module.exports = async (client) => {
// LOADING SLASH COMMANDS
try {
let arrayOfcommands = [];
const commandFiles = await globPromise(
`${process.cwd()}/Commands/Slash/**/*.js`
);
commandFiles.map((value) => {
const file = require(value);
const splitted = value.split("/");
const directory = splitted[splitted.length - 2];
const properties = { directory, ...file };
client.commands.set(file.name, properties);
arrayOfcommands.push(file);
});
client.on("ready", async () => {
await client.application.commands.set(arrayOfcommands);
// let guild = client.guilds.cache.get(client.config.guildID)
// await guild.commands.set(arrayOfcommands)
});
console.log(`${client.commands.size} Slash Commands Loaded`);
} catch (e) {
console.log(e);
}
// LOADING MESSAGE COMMANDS
try {
const MessageCommadsFiles = await globPromise(
`${process.cwd()}/Commands/Message/**/*.js`
);
MessageCommadsFiles.map((value) => {
const file = require(value);
const splitted = value.split("/");
const directory = splitted[splitted.length - 2];
const properties = { directory, ...file };
client.mcommands.set(file.name, properties);
if (file.aliases && Array.isArray(file.aliases))
file.aliases.forEach((a) => client.aliases.set(a, file.name));
});
console.log(`${client.mcommands.size} Message Commands Loaded`);
} catch (e) {
console.log(e);
}
// Loading Event Files
try {
const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);
eventFiles.map((value) => require(value));
console.log(`${eventFiles.length} Events Loaded`);
} catch (e) {
console.log(e);
}
};