make working leaderboard command
This commit is contained in:
parent
dd95984723
commit
4a55c2ebe3
|
@ -0,0 +1,25 @@
|
||||||
|
const db = require('quick.db')
|
||||||
|
module.exports = {
|
||||||
|
name: 'leaderboard',
|
||||||
|
description: 'List of tallests cactuses.',
|
||||||
|
execute(event, args, bot) {
|
||||||
|
data = db.all()
|
||||||
|
data.map(score => {
|
||||||
|
score.ID = score.ID.replace('_score','')
|
||||||
|
score.data = parseFloat(parseFloat(score.data).toFixed(3))
|
||||||
|
})
|
||||||
|
|
||||||
|
data.sort(function (a, b) {
|
||||||
|
return b.data - a.data
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(data)
|
||||||
|
|
||||||
|
let text = ""
|
||||||
|
for(let i = 0; i < 5; i++) {
|
||||||
|
text += `${i + 1}. ${data[i].ID} (${data[i].data} cm) `
|
||||||
|
}
|
||||||
|
|
||||||
|
bot.say(event.target, 'Cactus Leaderboard: ' + text)
|
||||||
|
},
|
||||||
|
};
|
Loading…
Reference in New Issue