CFLombardi / sethBot

The bot for the Good Job! discord server
MIT License
3 stars 0 forks source link

make the leaderboard function not stupid #31

Open Kydane opened 5 years ago

Kydane commented 5 years ago
karmaMap.forEach(function(value, key, dosh) {
        for (i = 0; i < karmaMap.size; i++) {  
            if(typeof leaderboard[i] === "undefined"){
                leaderboard.splice(i, 0, value );
                break;
            }
            if(value.totalCount > leaderboard[i].totalCount){
                leaderboard.splice(i, 0, value );
                break;
            }
            if(i+1 == karmaMap.size){
                leaderboard.push(value);
            }

        }
});

Why did I do this... i literally rewrote the stupid .sort command. Rewrite this to not do this janked up sorting and just use a simple .sort? If for some reason the util i'm using "Map()" doesn't have a sort function just leave it and close this issue. I just dont know why I did it like this looking back...