forked from AlexzanderFlores/WOKCommands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Command.js
91 lines (91 loc) · 3.18 KB
/
Command.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
83
84
85
86
87
88
89
90
91
"use strict";
var Command = /** @class */ (function () {
function Command(instance, client, names, callback, _a) {
var minArgs = _a.minArgs, maxArgs = _a.maxArgs, syntaxError = _a.syntaxError, expectedArgs = _a.expectedArgs, description = _a.description, requiredPermissions = _a.requiredPermissions;
this._names = [];
this._minArgs = 0;
this._maxArgs = -1;
this._requiredPermissions = [];
this._callback = function () { };
this.instance = instance;
this.client = client;
this._names = typeof names === 'string' ? [names] : names;
this._minArgs = minArgs || 0;
this._maxArgs = maxArgs === undefined ? -1 : maxArgs;
this._syntaxError = syntaxError;
this._expectedArgs = expectedArgs;
this._description = description;
this._requiredPermissions = requiredPermissions;
this._callback = callback;
if (this._minArgs < 0) {
throw new Error("Command \"" + names[0] + "\" has a minimum argument count less than 0!");
}
if (this._maxArgs < -1) {
throw new Error("Command \"" + names[0] + "\" has a maximum argument count less than -1!");
}
if (this._maxArgs !== -1 && this._maxArgs < this._minArgs) {
throw new Error("Command \"" + names[0] + "\" has a maximum argument count less than it's minimum argument count!");
}
}
Command.prototype.execute = function (message, args) {
this._callback(message, args, args.join(' '), this.client, this.instance.getPrefix(message.guild), this.instance);
};
Object.defineProperty(Command.prototype, "names", {
get: function () {
return this._names;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Command.prototype, "minArgs", {
get: function () {
return this._minArgs;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Command.prototype, "maxArgs", {
get: function () {
return this._maxArgs;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Command.prototype, "syntaxError", {
get: function () {
return this._syntaxError;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Command.prototype, "expectedArgs", {
get: function () {
return this._expectedArgs;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Command.prototype, "description", {
get: function () {
return this._description;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Command.prototype, "requiredPermissions", {
get: function () {
return this._requiredPermissions;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Command.prototype, "callback", {
get: function () {
return this._callback;
},
enumerable: false,
configurable: true
});
return Command;
}());
module.exports = Command;