Baphomet is the dedicated bot for nulloctet matrix
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.

36 lines
917 B

  1. /**
  2. * Help module
  3. */
  4. let { AbstractModule } = require('./abstract');
  5. let { logger } = require('../logging');
  6. class HelpModule extends AbstractModule {
  7. constructor(commandMap) {
  8. super(
  9. "Help",
  10. "Provide helpful information about other modules.",
  11. "help"
  12. );
  13. this.commandMap = commandMap;
  14. }
  15. addCommand(command, module) {
  16. logger.debug("Adding help for command %s against module %s", command, module.name);
  17. this.commands.push(command);
  18. }
  19. help() {
  20. let help = `!help <command>`;
  21. for (let command of Array.from(this.commandMap.keys()).sort()) {
  22. help += "\n!help " + command + " : " + this.commandMap.get(command).description;
  23. }
  24. return help;
  25. }
  26. }
  27. function create(commandMap) {
  28. return new HelpModule(commandMap);
  29. }
  30. exports.create = create;
  31. exports.module = new HelpModule();