This repository has been archived by the owner on Aug 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmdFramework.js
82 lines (59 loc) · 2.5 KB
/
cmdFramework.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//Discord command framework by Jowbly
const fs = require("fs");
const enmap = require("enmap");
module.exports.client = null;
module.exports. suggestionArray = new enmap();
module.exports.captchaArray = new enmap();
console.log(" ")
console.log("[FRAMEWORK] Discord.js command and event handler.")
console.log("[FRAMEWORK] Developed by: Jowbly")
console.log("[FRAMEWORK] Version: 1.0")
module.exports.loadEvents = function(){
console.log(" ")
console.log("[INFO] BOT loader has been started.")
console.log(" ")
fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
console.log(`[SUCCESS] Event ${eventName}.js loaded.`);
this.client.on(eventName, event.bind(null, this.client));
});
});
}
module.exports.loadCommands = function (){
this.client.sArray = this.suggestionArray;
this.client.cArray = this.captchaArray;
this.client.commands = new enmap();
fs.readdir("./commands/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(`./commands/${file}`);
let commandName = file.split(".")[0];
console.log(`[SUCCESS] Command ${commandName}.js loaded.`);
this.client.commands.set(commandName, event);
});
});
this.client.on("ready", () => {
console.log(" ")
console.log("[SUCCESS] Commands and events has been registered.")
console.log(" ")
console.log("[SUCCESS] Logged in "+this.client.user.username+"#"+this.client.user.discriminator+".");
});
this.client.on("message", (message) => {
if (message.author.bot) return;
var prefix = "!";
// Ignore messages not starting with the prefix (in config.json)
if (message.content.indexOf(prefix) !== 0) return;
// Our standard argument/command name definition.
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
// Grab the command data from the client.commands Enmap
const cmd = this.client.commands.get(command);
// If that command doesn't exist, silently exit and do nothing
if (!cmd) return;
if(message.channel.name != 'comandos') return;
cmd.run(this.client, message, args, this.suggestionArray);
});
}