3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-24 04:49:25 +01:00
dbot/modules/command/commands.js

40 lines
1.3 KiB
JavaScript
Raw Normal View History

var _ = require('underscore')._;
var commands = {
'~usage': function(event) {
var commandName = event.params[1];
if(_.has(this.dbot.usage, commandName)) {
event.reply(this.dbot.t('usage', {
'command': commandName,
'usage': this.dbot.usage[commandName]
}));
} else {
event.reply(this.dbot.t('no_usage_info', {
'command': commandName
}));
}
},
'~help': function(event) {
var moduleName = event.params[1];
if(!_.has(this.dbot.modules, moduleName)) {
var moduleName = this.dbot.commands[moduleName].module;
}
if(moduleName && _.has(this.dbot.config[moduleName], 'help')) {
var help = this.dbot.config[moduleName].help;
event.reply(this.dbot.t('help_link', {
'module': moduleName,
'link': help
}));
} else {
if(!moduleName) {
moduleName = event.params[1];
}
event.reply(this.dbot.t('no_help', { 'module': moduleName }))
}
}
};
exports.fetch = commands;