var modules = require('../modules.json');

function trigger(body, api, message) {
  var threadID = message.threadID;
  var helpMessage;
  if(body.length > 1) {
    helpMessage = formDesc(body);
  } else {
    helpMessage = formHelp();
  }
  api.sendMessage(helpMessage, threadID);
}

function formHelp() {
  var usageMessage = '```\nusage: [prefix|/][command] [<args>]\n\n'; 
  for(var module in modules) {
    usageMessage += modules[module].name;
    usageMessage += ' '.repeat(15-modules[module].name.length);
    usageMessage += '[' + modules[module].trigger + ']';
    usageMessage += '\n';
  }
  usageMessage += "help <command> lists available subcommands and descriptions" 
  return usageMessage;
}

function formDesc(cmd) {
  for(var module in modules) {
    if(cmd == modules[module].name) {
      var usageMessage = '```\n' + modules[module].name + ': ';
      usageMessage += modules[module].description + '\n';
      if(Object.keys(modules[module].usage).length > 0) {
        usageMessage += 'Commands begin with /' + modules[module].trigger + ':\n';
        for(var key in modules[module].usage) {
            usageMessage += key + ' - ';
            usageMessage += modules[module].usage[key] + '\n';
        }
      }
      usageMessage += '```';
    }
  }
  return usageMessage;
}

module.exports = {
  trigger: trigger
}

@@ -338,18 +338,9 @@
 e: %5B
-prefix%7C/%5D%5B
+/
 comm
@@ -358,13 +358,224 @@
 %3E%5D%5Cn
-%5Cn'; 
+Such as %22/echo hello world%22%5CnTo see a list of valid commands, send /help commands';%0A  return usageMessage;%0A%7D%0A%0Afunction formHelpCommands() %7B%0A%0A  var usageMessage = %22%60%60%60%5CnDescription   Command%5Cn----------------------%22;%0A
 %0A  f
@@ -814,16 +814,17 @@
 age += %22
+/
 help %3Cco
@@ -928,16 +928,133 @@
 (cmd) %7B%0A
+  console.log(cmd)%0A  if(cmd == %22commands%22) %7B%0A    console.log(formHelpCommands());%0A    return formHelpCommands();%0A  %7D%0A
   for(va

Make help less spammy