Create allbalance command to get list of everyone's currency
All checks were successful
Test / build (push) Successful in 9s
All checks were successful
Test / build (push) Successful in 9s
This commit is contained in:
parent
f28254e407
commit
39b1c8d14b
2 changed files with 30 additions and 0 deletions
28
src/commands/allbalance.ts
Normal file
28
src/commands/allbalance.ts
Normal 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 });
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ import { Environment } from "./constants/Environment";
|
||||||
|
|
||||||
// Global Command Imports
|
// Global Command Imports
|
||||||
import About from "./commands/about";
|
import About from "./commands/about";
|
||||||
|
import AllBalance from "./commands/allbalance";
|
||||||
import Balance from "./commands/balance";
|
import Balance from "./commands/balance";
|
||||||
import Daily from "./commands/daily";
|
import Daily from "./commands/daily";
|
||||||
import Drop from "./commands/drop";
|
import Drop from "./commands/drop";
|
||||||
|
@ -31,6 +32,7 @@ export default class Registry {
|
||||||
public static RegisterCommands() {
|
public static RegisterCommands() {
|
||||||
// Global Commands
|
// Global Commands
|
||||||
CoreClient.RegisterCommand("about", new About());
|
CoreClient.RegisterCommand("about", new About());
|
||||||
|
CoreClient.RegisterCommand("allbalance", new AllBalance());
|
||||||
CoreClient.RegisterCommand("balance", new Balance());
|
CoreClient.RegisterCommand("balance", new Balance());
|
||||||
CoreClient.RegisterCommand("daily", new Daily());
|
CoreClient.RegisterCommand("daily", new Daily());
|
||||||
CoreClient.RegisterCommand("drop", new Drop());
|
CoreClient.RegisterCommand("drop", new Drop());
|
||||||
|
|
Loading…
Reference in a new issue