From b232103178d41feacf8b60e9304476d9c1fe61b6 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Sun, 15 Apr 2012 20:46:42 +0100 Subject: [PATCH] Create command map describing which commands belong to which module. --- run.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run.js b/run.js index 9909a37..02d7ad1 100644 --- a/run.js +++ b/run.js @@ -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); } } }