From 19c3497f112a056e76aa6e4bc1b984b2755bf86c Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Tue, 11 Dec 2012 20:47:50 +0000 Subject: [PATCH] reload default strings in updateModules --- modules/admin/admin.js | 1 - run.js | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/admin/admin.js b/modules/admin/admin.js index 99e8a2e..d6fae5e 100644 --- a/modules/admin/admin.js +++ b/modules/admin/admin.js @@ -53,7 +53,6 @@ var admin = function(dbot) { // Reload DB, translations and modules. 'reload': function(event) { dbot.db = JSON.parse(fs.readFileSync('db.json', 'utf-8')); - dbot.strings = JSON.parse(fs.readFileSync('strings.json', 'utf-8')); dbot.reloadModules(); event.reply(dbot.t('reload')); }, diff --git a/run.js b/run.js index 129518a..e1b5f6e 100644 --- a/run.js +++ b/run.js @@ -151,11 +151,16 @@ DBot.prototype.reloadModules = function() { this.modules = []; this.commands = {}; this.commandMap = {}; // Map of which commands belong to which modules - this.strings = {}; this.usage = {}; this.timers.clearTimers(); this.save(); + try { + this.strings = JSON.parse(fs.readFileSync('strings.json', 'utf-8')); + } catch(err) { + this.strings = {}; + } + // Enforce having command. it can still be reloaded, but dbot _will not_ // function without it, so not having it should be impossible if(!this.moduleNames.include("command")) {