forked from GitHub/dbot
Create and/or fix a missing/incomplete DB on running.
This commit is contained in:
parent
a9a88723e3
commit
248ca9b790
26
run.js
26
run.js
@ -6,7 +6,33 @@ require('./snippets');
|
||||
var DBot = function(timers) {
|
||||
// Load external files
|
||||
this.config = JSON.parse(fs.readFileSync('config.json', 'utf-8'));
|
||||
try {
|
||||
this.db = JSON.parse(fs.readFileSync('db.json', 'utf-8'));
|
||||
} catch (e) {
|
||||
this.db = {};
|
||||
} finally { /* fill any missing parts of the db; if this is a new DB, that's all of them */
|
||||
if(!this.db.hasOwnProperty("bans")) {
|
||||
this.db.bans = {};
|
||||
}
|
||||
if(!this.db.bans.hasOwnProperty("*")) {
|
||||
this.db.bans["*"] = [];
|
||||
}
|
||||
if(!this.db.hasOwnProperty("quoteArrs")) {
|
||||
this.db.quoteArrs = {};
|
||||
}
|
||||
if(!this.db.hasOwnProperty("kicks")) {
|
||||
this.db.kicks = {};
|
||||
}
|
||||
if(!this.db.hasOwnProperty("kickers")) {
|
||||
this.db.kickers = {};
|
||||
}
|
||||
if(!this.db.hasOwnProperty("modehate")) {
|
||||
this.db.modehate = [];
|
||||
}
|
||||
if(!this.db.hasOwnProperty("locks")) {
|
||||
this.db.locks = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Populate bot properties with config data
|
||||
this.name = this.config.name || 'dbox';
|
||||
|
Loading…
Reference in New Issue
Block a user