Drew Short
5 years ago
7 changed files with 134 additions and 16 deletions
-
68bot/engine.js
-
6bot/module/abstract.js
-
37bot/module/help.js
-
21bot/utility.js
-
5package-lock.json
-
1package.json
@ -0,0 +1,37 @@ |
|||
/** |
|||
* Help module |
|||
*/ |
|||
|
|||
let { AbstractModule } = require('./abstract'); |
|||
let { logger } = require('../logging'); |
|||
|
|||
class HelpModule extends AbstractModule { |
|||
constructor(commandMap) { |
|||
super( |
|||
"Help", |
|||
"Provide helpful information about other modules.", |
|||
"help" |
|||
); |
|||
this.commandMap = commandMap; |
|||
} |
|||
|
|||
addCommand(command, module) { |
|||
logger.debug("Adding help for command %s against module %s", command, module.name); |
|||
this.commands.push(command); |
|||
} |
|||
|
|||
help() { |
|||
let help = `!help <command>`; |
|||
for (let command of Array.from(this.commandMap.keys()).sort()) { |
|||
help += "\n!help " + command + " : " + this.commandMap.get(command).description; |
|||
} |
|||
return help; |
|||
} |
|||
} |
|||
|
|||
function create(commandMap) { |
|||
return new HelpModule(commandMap); |
|||
} |
|||
|
|||
exports.create = create; |
|||
exports.module = new HelpModule(); |
Write
Preview
Loading…
Cancel
Save
Reference in new issue