From 6e727ed9d8f05419c46688933a12b0738cca99ee Mon Sep 17 00:00:00 2001 From: John Maguire Date: Mon, 18 Mar 2013 22:33:15 -0400 Subject: [PATCH] refactored DBot.prototype.t to error properly --- run.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/run.js b/run.js index fadc12b..d6237fc 100644 --- a/run.js +++ b/run.js @@ -86,16 +86,17 @@ DBot.prototype.say = function(server, channel, message) { // Format given stored string in config language DBot.prototype.t = function(string, formatData) { - var formattedString; + var formattedString = 'String not found. Something has gone screwy. Maybe.'; + if(_.has(this.strings, string)) { var lang = this.config.language; if(!_.has(this.strings[string], lang)) { lang = "en"; } - formattedString = this.strings[string][lang].format(formatData); - } else { - formattedString = 'String not found. Something has gone screwy. Maybe.'; + if(_.has(this.strings[string], lang)) { + formattedString = this.strings[string][lang].format(formatData); + } } return formattedString;