Create allbalance command to get list of everyone's currency #306

Merged
Vylpes merged 1 commit from feature/260-baltop-command into develop 2024-07-20 21:42:37 +01:00
2 changed files with 30 additions and 0 deletions
Showing only changes of commit 39b1c8d14b - Show all commits

View file

@ -0,0 +1,28 @@
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);
const filteredUsers = users.filter(x => x.Currency > 0);
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 });
}
}

View file

@ -3,6 +3,7 @@ import { Environment } from "./constants/Environment";
// Global Command Imports
import About from "./commands/about";
import AllBalance from "./commands/allbalance";
import Balance from "./commands/balance";
import Daily from "./commands/daily";
import Drop from "./commands/drop";
@ -31,6 +32,7 @@ export default class Registry {
public static RegisterCommands() {
// Global Commands
CoreClient.RegisterCommand("about", new About());
CoreClient.RegisterCommand("allbalance", new AllBalance());
CoreClient.RegisterCommand("balance", new Balance());
CoreClient.RegisterCommand("daily", new Daily());
CoreClient.RegisterCommand("drop", new Drop());