29 lines
688 B
JavaScript
29 lines
688 B
JavaScript
const db = require('quick.db')
|
|
module.exports = {
|
|
name: 'leaderboard',
|
|
description: 'List of tallests cactuses.',
|
|
execute (event, args, bot) {
|
|
const data = db.all()
|
|
data.map(score => {
|
|
score.ID = score.ID.replace('_score', '')
|
|
score.data = parseFloat(parseFloat(score.data).toFixed(3))
|
|
return 0
|
|
})
|
|
|
|
data.sort(function (a, b) {
|
|
return b.data - a.data
|
|
})
|
|
|
|
console.log(data)
|
|
|
|
let text = ''
|
|
for (let i = 0; i < 5; i++) {
|
|
if (data[i] !== undefined) {
|
|
text += `${i + 1}. ${data[i].ID[0]}\u200b${data[i].ID.substr(1)} (${data[i].data} cm) `
|
|
}
|
|
}
|
|
|
|
bot.say(event.target, 'Cactus Leaderboard: ' + text)
|
|
}
|
|
}
|