-
Notifications
You must be signed in to change notification settings - Fork 4
/
commands.js
70 lines (56 loc) · 1.31 KB
/
commands.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
var cmdFile = require("./commands.json");
var cmdLabel = cmdFile.label;
var cmdList = cmdFile.commands;
module.exports = {
getCommandLabel: function() {
return cmdLabel;
},
getCommandList: function() {
return cmdList;
},
getNumberOfCommands: function() {
return cmdFile.num_commands;
},
// Functions that use commands
getCommandID: function(cmd) {
return cmd.id
},
getCommandScope: function(cmd) {
/*
NOT YET IMPLEMENTED
-1 = admins only
0 = everyone
*/
return cmd.scope;
},
getCommandHelp: function(cmd) {
return cmd.help;
},
getCommandDescription: function(cmd) {
return cmd.desc;
},
// Function that use data
stripLabel: function(m) {
return m.substring(cmdLabel.length);
},
getCommandArguments: function(data) {
var cmdArgs = data.split(" ");
if(cmdArgs[0].startsWith(cmdLabel)) cmdArgs[0] = this.stripLabel(cmdArgs[0]);
return cmdArgs;
},
getCommand: function(data) {
var cmd = this.getRawCommand(data);
if(cmd !== undefined && cmd.alias !== undefined) return cmdList[cmd.alias];
return cmd;
},
getRawCommand: function(data) {
return cmdList[this.getCommandArguments(data)[0]];
},
isCommand: function(data) {
if(data.startsWith(cmdLabel)) {
var temp = this.getCommand(data);
return temp !== null && temp !== undefined;
}
return false;
}
}