-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.js
More file actions
32 lines (29 loc) · 780 Bytes
/
command.js
File metadata and controls
32 lines (29 loc) · 780 Bytes
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
var actionFactory = require("./action").actionFactory;
class Command {
constructor(options) {
this.name = options.name;
this.level = options.level;
this.cooldown = options.cooldown || 10;
this.action = options.action;
if (!this.action) {
actionFactory
.createAction(options.data)
.then(action => {
this.action = action;
})
.catch(e => console.log(e));
}
}
run(bot, from, to, args) {
return new Promise((resolve, reject) => {
if (!this.action) reject();
if (typeof this.action === "function") {
this.action(bot, from, to, args);
} else if (this.action) {
this.action.execute(bot, from, to, args);
}
resolve();
});
}
}
module.exports = Command;