/** * 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 `; 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();