From 163209afb9c75c0a88502303b9ea591b1c216116 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Wed, 20 Mar 2013 17:47:01 -0400 Subject: [PATCH] adding some extra checks to ~help command to prevent errors --- modules/command/commands.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/command/commands.js b/modules/command/commands.js index 96ac77a..69ec05f 100644 --- a/modules/command/commands.js +++ b/modules/command/commands.js @@ -18,8 +18,20 @@ var commands = function(dbot) { '~help': function(event) { var moduleName = event.params[1]; + if(!moduleName) { + event.reply(dbot.t('usage', { + 'command': '~help', + 'usage': '~help [module]' + })); + return; + } + if(!_.has(dbot.modules, moduleName)) { - var moduleName = dbot.commands[moduleName].module; + if(_.has(dbot.commands, moduleName)) { + var moduleName = dbot.commands[moduleName].module; + } else { + var moduleName = undefined; + } } if(moduleName && _.has(dbot.config[moduleName], 'help')) {