forked from FallenAngel65/command-handler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.js
More file actions
34 lines (32 loc) · 1.36 KB
/
Copy pathModule.js
File metadata and controls
34 lines (32 loc) · 1.36 KB
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
const {Collection} = require("discord.js"), {readdir} = require("fs"), homePath = process.cwd();
module.exports = client => {
client.commands = new Collection();
client.aliases = new Collection();
client.helps = new Collection();
readdir(`${homePath}/commands/`, (err, categories) => {
if (err) console.log(err);
console.log(`[available] ${categories.length} category`);
categories.forEach(category => {
let moduleConf = require(`${homePath}/commands/${category}/module.json`);
if (moduleConf) {
moduleConf.path = `${homePath}/commands/${category}`;
moduleConf.cmds = [];
client.helps.set(category, moduleConf);
readdir(`${homePath}/commands/${category}`, (err, files) => {
console.log(`[available] ${files.length - 1} cmds - ${category} category`);
if (err) console.log(err);
// let commands = new Array();
files.forEach(file => {
if (file.endsWith(".js")) {
let prop = require(`${homePath}/commands/${category}/${file}`);
// let cmdName = file.split(".")[0];
client.commands.set(prop.help.name, prop);
prop.conf.aliases.forEach(alias => client.aliases.set(alias, prop.help.name));
client.helps.get(category).cmds.push(prop.help.name);
};
});
});
};
});
});
};