-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathcommand_generator.js
49 lines (40 loc) · 930 Bytes
/
command_generator.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
const path = require("path")
module.exports = {
create: function(commandId, commandDir) {
var _id = commandId
var _triggers = []
var _description = ""
var _showBalloon = false
var _source = require(path.resolve(commandDir, _id + ".js"))
this.id = function() {
return _id
}
this.triggers = function() {
return _triggers
}
this.setTriggers = function(triggers) {
_triggers = triggers
}
this.description = function() {
return _description
}
this.setDescription = function(description) {
_description = description
}
this.showBalloon = function() {
return _showBalloon
}
this.setShowBalloon = function(showBalloon) {
_showBalloon = showBalloon
}
this.run = function(args, next) {
try {
_source.run(args, next)
}
catch(error) {
next(":warning: This command is crashing. Check the console logs for more info.")
console.log(error)
}
}
}
}