2024-07-20 21:42:37 +01:00
|
|
|
import { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
|
|
|
import EmbedColours from "../constants/EmbedColours";
|
|
|
|
import { Command } from "../type/command";
|
|
|
|
import User from "../database/entities/app/User";
|
|
|
|
|
|
|
|
export default class AllBalance extends Command {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.CommandBuilder = new SlashCommandBuilder()
|
|
|
|
.setName("allbalance")
|
|
|
|
.setDescription("Get everyone's currency balance")
|
|
|
|
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async execute(interaction: CommandInteraction) {
|
|
|
|
const users = await User.FetchAll(User);
|
|
|
|
|
2024-07-26 18:29:57 +01:00
|
|
|
const filteredUsers = users.filter(x => x.Currency > 0)
|
|
|
|
.sort((a, b) => b.Currency - a.Currency);
|
2024-07-20 21:42:37 +01:00
|
|
|
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setColor(EmbedColours.Ok)
|
|
|
|
.setTitle("All Balances")
|
|
|
|
.setDescription(filteredUsers.map(x => `<@${x.Id}> ${x.Currency}`).join("\n"));
|
|
|
|
|
|
|
|
await interaction.reply({ embeds: [ embed ], ephemeral: true });
|
|
|
|
}
|
|
|
|
}
|