-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommandLoader.js
46 lines (35 loc) · 1.17 KB
/
commandLoader.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
const glob = require ('glob')
/**
* This class manages all of the command js file inthe "modules" folder
*/
class CommandLoader {
constructor(){}
//Loads Commands
async loadCommands(client){
// Get all event scripts
glob('./events/*.js', [], (err, files) =>{
files.map((value) => {
require(value)
})
})
// Get Command files
var commandArray = []
glob('./modules/commands/**/*.js', [], (err, files) =>{
files.map((value) => {
// Require all loaded files
const file = require(value)
if(!file?.name) return console.log(`File ${value} doesn't have a "name" param`)
commandArray.push(file)
client.commands.set(file.name, file)
client.commandInfo.set(file.name, file.description)
})
})
// Register Commands to bot when bot is running
client.on("ready", async () => {
client.guilds.cache
.get('789252395015733248')
.commands.set(commandArray)
});
}
}
module.exports = CommandLoader