-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.js
More file actions
36 lines (31 loc) · 1.11 KB
/
command.js
File metadata and controls
36 lines (31 loc) · 1.11 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
35
36
const fs = require('fs');
const configs = require('./config.json');
exports.init = async () => {
console.log("Command Handler has started!")
}
exports.exec = async (client, args, command, message) => {
if (!message.content.startsWith(configs.prefix)) return
const dir = await fs.promises.opendir(__dirname + "/cmds/");
for await (const dirent of dir) {
if (!dirent.isFile) return;
if (dirent.name == command + ".js") {
try {
let cmd = require(`./cmds/${dirent.name}`)
cmd.command(client, args, command, message)
} catch (e) {
console.log(e)
}
}
}
if (command == "reload") {
if (message.author.id == configs.botowner) {
if (args[0]) {
delete require.cache[require.resolve(`./cmds/${args[0]}.js`)];
message.channel.send(` Reloading command "${args[0]}"`)
console.log(`Reloading ${args[0]}`)
}else {
message.channel.send("Missing argument")
}
}
}
}