You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
917 B
37 lines
917 B
/**
|
|
* 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();
|