From 27c150f877589b12414cb76df58e6763e22e941a Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Sun, 9 Nov 2014 13:59:00 +0000 Subject: [PATCH] some ufixes --- modules/sstats/commands.js | 5 ++++- modules/sstats/sstats.js | 5 ++++- modules/warning/warning.js | 42 +++++++++++++++++++++----------------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/modules/sstats/commands.js b/modules/sstats/commands.js index 356eab3..57e89c6 100644 --- a/modules/sstats/commands.js +++ b/modules/sstats/commands.js @@ -214,7 +214,10 @@ var commands = function(dbot) { async.eachSeries(pCounts, function(pCount, next) { dbot.api.users.getUser(pCount[0], function(err, user) { - pCount[0] = user.primaryNick; next(); + if(user) { + pCount[0] = user.primaryNick; + } + next(); }); }, function() { event.reply(this.internalAPI.formatHighscore('Top ' + word + ' users: ', pCounts)); diff --git a/modules/sstats/sstats.js b/modules/sstats/sstats.js index 71a4ac8..6232c21 100644 --- a/modules/sstats/sstats.js +++ b/modules/sstats/sstats.js @@ -48,7 +48,10 @@ var sstats = function(dbot) { async.eachSeries(pCounts, function(pCount, next) { dbot.api.users.getUser(pCount[0], function(err, user) { - pCount[0] = user.primaryNick; next(); + if(user) { + pCount[0] = user.primaryNick; + } + next(); }); }, function() { callback(pCounts); diff --git a/modules/warning/warning.js b/modules/warning/warning.js index e5f1a89..6de4977 100644 --- a/modules/warning/warning.js +++ b/modules/warning/warning.js @@ -76,25 +76,29 @@ var warning = function(dbot) { server = event.server; dbot.api.users.resolveUser(server, warnee, function(err, warnee) { - var warnings = 0; - this.db.search('warnings', { - 'server': server, - 'warnee': warnee.id - }, function(warning) { - warnings++; - }, function(err) { - if(warnings > 0) { - event.reply(dbot.t('warning_info', { - 'user': warnee.primaryNick, - 'num': warnings, - 'url': dbot.api.web.getUrl('warning/' + server + '/' - + warnee.primaryNick) - })); - } else { - event.reply(dbot.t('no_warnings', { 'user': - warnee.primaryNick })); - } - }); + if(warnee) { + var warnings = 0; + this.db.search('warnings', { + 'server': server, + 'warnee': warnee.id + }, function(warning) { + warnings++; + }, function(err) { + if(warnings > 0) { + event.reply(dbot.t('warning_info', { + 'user': warnee.primaryNick, + 'num': warnings, + 'url': dbot.api.web.getUrl('warning/' + server + '/' + + warnee.primaryNick) + })); + } else { + event.reply(dbot.t('no_warnings', { 'user': + warnee.primaryNick })); + } + }); + } else { + event.reply(event.params[1] + ' not found.'); + } }.bind(this)); } };