nyx/commands/Economy/lb.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-06-12 12:53:51 +02:00
const Levels = require("discord-xp");
const { Client, Message, MessageEmbed } = require("discord.js");
module.exports = {
name: "leaderboard",
aliases: ["lb"],
timeout: 5000,
usage: "Check the leaderboard of a server",
category: "Economy",
2021-07-13 05:17:39 +02:00
Level: true,
2021-06-12 12:53:51 +02:00
run: async (client, message, args) => {
const rawLeaderboard = await Levels.fetchLeaderboard(message.guild.id, 10);
if (rawLeaderboard.length < 1)
return client.err(message, "Economy", "lb", 10);
const leaderboard = await Levels.computeLeaderboard(
client,
rawLeaderboard,
true
);
const lb = leaderboard.map(
e =>
`**${e.position}**. ${e.username}#${e.discriminator} Level: ${
e.level
} XP: ${e.xp.toLocaleString()}`
);
const embed = new MessageEmbed()
.setTitle(`**Leaderboard for ${message.guild.name}**`)
.setDescription(`\n${lb.join("\n")}`)
.setFooter(
`Requested by ${message.author.tag}`,
message.author.displayAvatarURL({ dynamic: true })
)
.setColor(client.color);
2021-09-06 12:38:25 +02:00
message.reply(embed);
2021-06-12 12:53:51 +02:00
},
};