diff --git a/commands/leaderboard.js b/commands/leaderboard.js new file mode 100644 index 0000000..586c329 --- /dev/null +++ b/commands/leaderboard.js @@ -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) + }, +}; \ No newline at end of file