mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
basic dependencies as per [#85]
This commit is contained in:
parent
5485c39684
commit
1673c8846b
@ -1,5 +1,6 @@
|
||||
{
|
||||
"help": "http://github.com/reality/depressionbot/blob/master/modules/poll/README.md",
|
||||
"dbKeys": [ "polls" ],
|
||||
"ignorable": true
|
||||
"ignorable": true,
|
||||
"dependencies": [ "users", "command" ]
|
||||
}
|
||||
|
19
run.js
19
run.js
@ -178,7 +178,22 @@ DBot.prototype.reloadModules = function() {
|
||||
// Invalid or no config data
|
||||
}
|
||||
|
||||
// Load module config
|
||||
// Shit out if dependencies not met
|
||||
if(_.has(config, 'dependencies')) {
|
||||
var unmetDependencies = _.reduce(config.dependencies, function(memo, dependency) {
|
||||
if(!_.include(moduleNames, dependency)) {
|
||||
memo.push(dependency);
|
||||
}
|
||||
return memo;
|
||||
}, [], this);
|
||||
|
||||
if(unmetDependencies.length != 0) {
|
||||
throw new Error("Dependencies not met: " + unmetDependencies);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate missing DB keys
|
||||
this.config[name] = config;
|
||||
_.each(config.dbKeys, function(dbKey) {
|
||||
if(!_.has(this.db, dbKey)) {
|
||||
@ -186,8 +201,6 @@ DBot.prototype.reloadModules = function() {
|
||||
}
|
||||
}, this);
|
||||
|
||||
// Override module config with any stored in the DB
|
||||
|
||||
// Load the module itself
|
||||
var rawModule = require(moduleDir + name);
|
||||
var module = rawModule.fetch(this);
|
||||
|
Loading…
Reference in New Issue
Block a user