-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.js
40 lines (35 loc) · 909 Bytes
/
Plugin.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
const util = require('util');
module.exports = class {
constructor(name, version, description, bot) {
this.name = name;
this.log = require('./newLog')(`?${name}`);
this.log.important('Hello, bot!');
this.version = version;
this.description = description;
this.bot = bot;
this.eventHandlers = {};
this.commands = {};
this.groups = {};
this.helpEntries = {};
}
[util.inspect.custom]() {
return `<Plugin name='${this.name}'>`;
}
addHelp(name, entry) {
this.helpEntries[name] = entry;
}
newCommand(name) {
let c = new (require('./Command'))(name);
this.commands[name] = c;
return c;
}
newGroup(name) {
let g = new Set();
g.addCmd = (cmd, branch) => {
g.add(this.name + '/' + cmd + '/' + branch);
return g;
}
this.groups[name] = g;
return g;
}
}