3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 22:39:26 +01:00

Merge pull request #315 from JohnMaguire2013/help

adding some extra checks to ~help command to prevent errors
This commit is contained in:
reality 2013-03-21 01:58:35 -07:00
commit d197a30b17
2 changed files with 23 additions and 1 deletions

View File

@ -18,8 +18,27 @@ var commands = function(dbot) {
'~help': function(event) {
var moduleName = event.params[1];
if(!moduleName) {
helpfulModules = _.filter(dbot.modules, function(element, index, array) {
return _.has(dbot.config[element], 'help');
});
event.reply(dbot.t('usage', {
'command': '~help',
'usage': '~help [module]'
}));
event.reply(dbot.t('loaded_modules_with_help', {
'modules': helpfulModules.join(', ')
}));
return;
}
if(!_.has(dbot.modules, moduleName)) {
if(_.has(dbot.commands, moduleName)) {
var moduleName = dbot.commands[moduleName].module;
} else {
var moduleName = undefined;
}
}
if(moduleName && _.has(dbot.config[moduleName], 'help')) {

View File

@ -26,5 +26,8 @@
"no_help": {
"en": "No help found for {module}.",
"na'vi": "Fì{module}ìri oel ke tsun run srungit"
},
"loaded_modules_with_help": {
"en": "Loaded modules with help information: {modules}."
}
}