From 63ded5b1972958ef34f5ff656d3f9e5637147ac7 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 8 Sep 2014 10:41:09 +0000 Subject: [PATCH] that should do it --- modules/quotes/quotes.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/quotes/quotes.js b/modules/quotes/quotes.js index 004d4a0..66d565f 100644 --- a/modules/quotes/quotes.js +++ b/modules/quotes/quotes.js @@ -16,11 +16,14 @@ var quotes = function(dbot) { if(quoteRefs) { var ref = this.internalAPI.cleanRef(quoteRefs[0].replace(/^~~/,'').replace(/~~$/,'').trim()); if(ref === '-nicks-') { - dbot.api.users.getRandomChannelUser(server, channel, function(user) { - quote = quote.replace('~~' + ref + '~~', user); + if(_.has(dbot.instance.connections[server].channels, channel)) { + var nicks = + _.keys(dbot.instance.connections[server].channels[channel].nicks); + var randomUser = nicks[_.random(0, nicks.length -1)]; + quote = quote.replace('~~' + ref + '~~', randomUser); this.internalAPI.interpolatedQuote(server, channel, username, key, quote, callback); - }.bind(this)); + } } else if(ref === '-nick-') { quote = quote.replace('~~' + ref + '~~', username); this.internalAPI.interpolatedQuote(server, channel,