diff --git a/modules/sstats/commands.js b/modules/sstats/commands.js index e7b661f..7d28d92 100644 --- a/modules/sstats/commands.js +++ b/modules/sstats/commands.js @@ -78,59 +78,28 @@ var commands = function(dbot) { // TODO: too much repeated code between loudest and cloudest yo '~loudest': function(event) { - var lines = {}; - this.db.scan('user_stats', function(uStats) { - lines[uStats.id] = uStats.lines; - }, function() { - var lCounts = _.chain(lines) - .pairs() - .sortBy(function(user) { return user[1]; }) - .reverse() - .first(10) - .value(); - + this.internalAPI.highscore('user_stats', 'lines', function(lCounts) { async.eachSeries(lCounts, function(lCount, next) { dbot.api.users.getUser(lCount[0], function(user) { - lCount[0] = user.primaryNick; - next(); + lCount[0] = user.primaryNick; next(); }); }, function() { - var output = "Loudest users: "; - for(var i=0;i