Create command map describing which commands belong to which module.

This commit is contained in:
Luke Slater 2012-04-15 20:46:42 +01:00
parent 0ecca6ae98
commit b232103178

3
run.js
View File

@ -120,10 +120,12 @@ DBot.prototype.reloadModules = function() {
this.moduleNames.each(function(name) {
var cacheKey = require.resolve('./modules/' + name);
delete require.cache[cacheKey];
try {
var rawModule = require('./modules/' + name);
var module = rawModule.fetch(this);
this.rawModules.push(rawModule);
this.commandMap[name] = [];
if(module.listener) {
this.instance.addListener(module.on, module.listener);
@ -134,6 +136,7 @@ DBot.prototype.reloadModules = function() {
for(key in newCommands) {
if(newCommands.hasOwnProperty(key) && Object.prototype.isFunction(newCommands[key])) {
this.commands[key] = newCommands[key];
this.commandMap[name].push(key);
}
}
}