38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
|
const { MessageEmbed } = require('discord.js');
|
||
|
const db = require('quick.db');
|
||
|
|
||
|
module.exports = {
|
||
|
|
||
|
name: "leaderboard",
|
||
|
aliases: ['lb'],
|
||
|
category: 'economy',
|
||
|
description: 'Zeigt Servers Top 10 Benutzer der Economy-Bestenliste',
|
||
|
usage: ' ',
|
||
|
accessableby: "everyone"
|
||
|
,
|
||
|
run: async (bot, message, args) => {
|
||
|
let money = db.all().filter(data => data.ID.startsWith(`money_`)).sort((a, b) => b.data - a.data);
|
||
|
if (!money.length) {
|
||
|
let noEmbed = new MessageEmbed()
|
||
|
.setAuthor(message.member.displayName, message.author.displayAvatarURL())
|
||
|
.setColor("GREEN")
|
||
|
.setFooter("Hier gibt es noch nichts zu sehen!")
|
||
|
return message.channel.send(noEmbed)
|
||
|
};
|
||
|
|
||
|
money.length = 10;
|
||
|
var finalLb = "";
|
||
|
for (var i in money) {
|
||
|
if (money[i].data === null) money[i].data = 0
|
||
|
finalLb += `**${money.indexOf(money[i]) + 1}. ${bot.users.cache.get(money[i].ID.split('_')[1]) ? bot.users.cache.get(money[i].ID.split('_')[1]).tag : "Unbekannter Benutzer#0000"}** - ${money[i].data} :euro:\n`;
|
||
|
};
|
||
|
|
||
|
const embed = new MessageEmbed()
|
||
|
.setTitle(`Leaderboard Of ${message.guild.name}`)
|
||
|
.setColor("GREEN")
|
||
|
.setDescription(finalLb)
|
||
|
.setFooter(bot.user.tag, bot.user.displayAvatarURL())
|
||
|
.setTimestamp()
|
||
|
message.channel.send(embed);
|
||
|
}
|
||
|
};
|