forked from GitHub/dbot
Create command map describing which commands belong to which module.
This commit is contained in:
parent
0ecca6ae98
commit
b232103178
3
run.js
3
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user