2022-10-26 12:38:28 +02:00
|
|
|
|
const { Collection, EmbedBuilder } = require("discord.js");
|
2021-09-06 12:38:25 +02:00
|
|
|
|
module.exports = {
|
|
|
|
|
name: "rich",
|
|
|
|
|
description: "Displaying top 10 richest users.",
|
|
|
|
|
category: "Economy",
|
2021-11-18 18:56:42 +01:00
|
|
|
|
timeout: 4000,
|
|
|
|
|
run: async (client, interaction) => {
|
2021-09-06 12:38:25 +02:00
|
|
|
|
const collection = new Collection();
|
|
|
|
|
await Promise.all(
|
|
|
|
|
interaction.guild.members.cache.map(async member => {
|
|
|
|
|
const id = member.id;
|
|
|
|
|
const bal = await client.bal(id);
|
|
|
|
|
if (!bal) return;
|
|
|
|
|
return bal !== 0
|
|
|
|
|
? collection.set(id, {
|
|
|
|
|
id,
|
|
|
|
|
bal,
|
|
|
|
|
})
|
|
|
|
|
: null;
|
|
|
|
|
})
|
|
|
|
|
);
|
2021-11-18 18:56:42 +01:00
|
|
|
|
if (!collection) {
|
|
|
|
|
return interaction.followUp({
|
2021-09-06 12:38:25 +02:00
|
|
|
|
content: `None of the members got ${client.currency}!`,
|
|
|
|
|
});
|
2021-11-18 18:56:42 +01:00
|
|
|
|
}
|
2021-09-06 12:38:25 +02:00
|
|
|
|
const ata = collection.sort((a, b) => b.bal - a.bal).first(10);
|
2021-11-18 18:56:42 +01:00
|
|
|
|
interaction.followUp({
|
2021-09-06 12:38:25 +02:00
|
|
|
|
embeds: [
|
2022-10-26 12:38:28 +02:00
|
|
|
|
new EmbedBuilder()
|
2021-09-06 12:38:25 +02:00
|
|
|
|
.setTitle(`Richest users in ${interaction.guild.name}`)
|
|
|
|
|
.setDescription(
|
|
|
|
|
ata
|
|
|
|
|
.map((v, i) => {
|
2021-11-18 18:56:42 +01:00
|
|
|
|
return `**${i + 1}❯** ${
|
2021-09-06 12:38:25 +02:00
|
|
|
|
interaction.guild.members.cache.get(v.id).user.tag
|
2021-11-18 18:56:42 +01:00
|
|
|
|
} =❯ **${v.bal} ${client.currency}**`;
|
2021-09-06 12:38:25 +02:00
|
|
|
|
})
|
|
|
|
|
.join("\n")
|
|
|
|
|
)
|
2022-10-26 12:38:28 +02:00
|
|
|
|
.setFooter({
|
|
|
|
|
text: `Made by ${client.author}`,
|
|
|
|
|
iconURL: client.user.displayAvatarURL(),
|
|
|
|
|
})
|
2021-09-06 12:38:25 +02:00
|
|
|
|
.setTimestamp()
|
|
|
|
|
.setColor(client.color),
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
};
|