Add balance command (#244)
# Description Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. - Create balance command #228 ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) # How Has This Been Tested? Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration. # Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that provde my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules Reviewed-on: #244 Reviewed-by: VylpesTester <tester@vylpes.com> Co-authored-by: Ethan Lane <ethan@vylpes.com> Co-committed-by: Ethan Lane <ethan@vylpes.com>
This commit is contained in:
parent
696810e093
commit
916244b57c
2 changed files with 30 additions and 0 deletions
28
src/commands/balance.ts
Normal file
28
src/commands/balance.ts
Normal file
|
@ -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 ]});
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 Balance from "./commands/balance";
|
||||||
import Daily from "./commands/daily";
|
import Daily from "./commands/daily";
|
||||||
import Drop from "./commands/drop";
|
import Drop from "./commands/drop";
|
||||||
import Gdrivesync from "./commands/gdrivesync";
|
import Gdrivesync from "./commands/gdrivesync";
|
||||||
|
@ -30,6 +31,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("balance", new Balance());
|
||||||
CoreClient.RegisterCommand("daily", new Daily());
|
CoreClient.RegisterCommand("daily", new Daily());
|
||||||
CoreClient.RegisterCommand("drop", new Drop());
|
CoreClient.RegisterCommand("drop", new Drop());
|
||||||
CoreClient.RegisterCommand("gdrivesync", new Gdrivesync());
|
CoreClient.RegisterCommand("gdrivesync", new Gdrivesync());
|
||||||
|
|
Loading…
Reference in a new issue