mirror of
https://github.com/reality/dbot.git
synced 2024-12-25 04:02:39 +01:00
kickstats
This commit is contained in:
parent
cbd96fb765
commit
50e7b46047
@ -34,7 +34,26 @@ var userCommands = function(dbot) {
|
|||||||
|
|
||||||
var orderedKicks = kickArr.sort(function(a, b) { return a[1] - b[1]; });
|
var orderedKicks = kickArr.sort(function(a, b) { return a[1] - b[1]; });
|
||||||
var topKicks = kickArr.slice(kickArr.length - 5).reverse();
|
var topKicks = kickArr.slice(kickArr.length - 5).reverse();
|
||||||
var kickString = "Top Kicks: ";
|
var kickString = "Top Kicked: ";
|
||||||
|
|
||||||
|
for(var i=0;i<topKicks.length;i++) {
|
||||||
|
kickString += topKicks[i][0] + " (" + topKicks[i][1] + "), ";
|
||||||
|
}
|
||||||
|
kickString = kickString.slice(0, -2);
|
||||||
|
|
||||||
|
dbot.say(data.channel, kickString);
|
||||||
|
|
||||||
|
// code repetition bad
|
||||||
|
var kickArr = [];
|
||||||
|
for(var kickUser in dbot.db.kickers) {
|
||||||
|
if(dbot.db.kickers.hasOwnProperty(kickUser)) {
|
||||||
|
kickArr.push([kickUser, dbot.db.kickers[kickUser]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var orderedKicks = kickArr.sort(function(a, b) { return a[1] - b[1]; });
|
||||||
|
var topKicks = kickArr.slice(kickArr.length - 5).reverse();
|
||||||
|
var kickString = "Top Kickers: ";
|
||||||
|
|
||||||
for(var i=0;i<topKicks.length;i++) {
|
for(var i=0;i<topKicks.length;i++) {
|
||||||
kickString += topKicks[i][0] + " (" + topKicks[i][1] + "), ";
|
kickString += topKicks[i][0] + " (" + topKicks[i][1] + "), ";
|
||||||
|
Loading…
Reference in New Issue
Block a user