forked from Simpleboy353/REAPER-2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadCommands.js
35 lines (32 loc) · 1004 Bytes
/
loadCommands.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
function loadCommands(client) {
const fs = require("fs");
const ascii = require("ascii-table");
const table = new ascii().setHeading("Commands", "Load Status");
const commandFolders = fs.readdirSync("./Commands");
for (const folder of commandFolders) {
const commandFiles = fs
.readdirSync(`./Commands/${folder}`)
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`../Commands/${folder}/${file}`);
if (command.name) {
client.commands.set(command.name, command);
table.addRow(file, "✔️");
} else {
table.addRow(
file,
"❌ => Missing a help.name or help.name is not in string"
);
continue;
}
if (command.aliases && Array.isArray(command))
command.aliases.forEach((alias) =>
client.aliases.set(alias, command.name)
);
}
console.log(table.toString());
}
}
module.exports = {
loadCommands,
};