From 146e7afa5be7a28bd8b238cd2eba3a2778e802cf Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 19 Apr 2013 17:06:19 +0000 Subject: [PATCH] Don't shit out if there's no highscore quote category --- modules/imgur/pages.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/imgur/pages.js b/modules/imgur/pages.js index 0d43f25..314dfee 100644 --- a/modules/imgur/pages.js +++ b/modules/imgur/pages.js @@ -3,9 +3,14 @@ var _ = require('underscore')._; var pages = function(dbot) { return { '/imgur/random': function(req, res) { - var hs = dbot.db.quoteArrs[dbot.config.imgur.highscore]; - hs = hs[hs.length-1]; - res.render('imgurr', {"highscore" : hs }); + var quoteCat = dbot.db.quoteArrs[dbot.config.imgur.highscore], + highScore = 0; + + if(quoteCat) { + highScore = _.last(quoteCat); + } + + res.render('imgurr', { "highscore" : highScore }); }, '/imgur/stats': function(req, res) {