diff --git a/src/commands/balance.ts b/src/commands/balance.ts new file mode 100644 index 0000000..2dcba50 --- /dev/null +++ b/src/commands/balance.ts @@ -0,0 +1,28 @@ +import { CommandInteraction, EmbedBuilder, SlashCommandBuilder } from "discord.js"; +import { Command } from "../type/command"; +import User from "../database/entities/app/User"; +import EmbedColours from "../constants/EmbedColours"; + +export default class Balance extends Command { + constructor() { + super(); + + this.CommandBuilder = new SlashCommandBuilder() + .setName("balance") + .setDescription("Get your currency balance"); + } + + public override async execute(interaction: CommandInteraction) { + const user = await User.FetchOneById(User, interaction.user.id); + + let userBalance = user != null ? user.Currency : 0; + + const embed = new EmbedBuilder() + .setColor(EmbedColours.Ok) + .setTitle("Balance") + .setDescription(`You currently have **${userBalance} currency**!`) + .setFooter({ text: interaction.user.username, iconURL: interaction.user.avatarURL() ?? undefined }); + + await interaction.reply({ embeds: [ embed ]}); + } +} \ No newline at end of file diff --git a/src/registry.ts b/src/registry.ts index dc2770d..182418e 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -3,6 +3,7 @@ import { Environment } from "./constants/Environment"; // Global Command Imports import About from "./commands/about"; +import Balance from "./commands/balance"; import Daily from "./commands/daily"; import Drop from "./commands/drop"; import Gdrivesync from "./commands/gdrivesync"; @@ -30,6 +31,7 @@ export default class Registry { public static RegisterCommands() { // Global Commands CoreClient.RegisterCommand("about", new About()); + CoreClient.RegisterCommand("balance", new Balance()); CoreClient.RegisterCommand("daily", new Daily()); CoreClient.RegisterCommand("drop", new Drop()); CoreClient.RegisterCommand("gdrivesync", new Gdrivesync());