diff --git a/run.js b/run.js index a32c869..5ee0d3d 100644 --- a/run.js +++ b/run.js @@ -157,7 +157,6 @@ DBot.prototype.reloadModules = function() { this.instance.removeListeners(); moduleNames.each(function(name) { - this.status[name] = true; var moduleDir = './modules/' + name + '/'; var cacheKey = require.resolve(moduleDir + name); delete require.cache[cacheKey]; @@ -170,6 +169,8 @@ DBot.prototype.reloadModules = function() { delete require.cache[webKey]; } + this.status[name] = true; + try { // Load the module config data var config = {}; @@ -191,19 +192,14 @@ DBot.prototype.reloadModules = function() { // Invalid or no config data } - // Shit out if dependencies not met + // Don't shit out if dependencies not met if(_.has(config, 'dependencies')) { - var unmetDependencies = _.reduce(config.dependencies, function(memo, dependency) { + _.each(config.dependencies, function(dependency) { if(!_.include(moduleNames, dependency)) { - memo.push(dependency); + console.log('Warning: Automatically loading ' + dependency); + moduleNames.push(dependency); } - return memo; - }, [], this); - - if(unmetDependencies.length != 0) { - this.status[name] = 'Dependencies not met: ' + unmetDependencies; - return; - } + }, this); } // Generate missing DB keys