# Description - Create a command to generate an embed for the user to be able to buy more effects - This embed will contain the details about the effect as well as 2 buttons; Confirm and Cancel - The confirm button will call the button event to: - Remove the currency from the user - Give the user the effect to their inventory - The cancel button will just disable the buttons, so the user can't accidentally use it if they don't want to. #381 ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) # How Has This Been Tested? - Have created unit tests and tested locally # 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: #424 Reviewed-by: VylpesTester <tester@vylpes.com> Co-authored-by: Ethan Lane <ethan@vylpes.com> Co-committed-by: Ethan Lane <ethan@vylpes.com>
64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
|
|
import { Command } from "../type/command";
|
|
import { EffectChoices } from "../constants/EffectDetails";
|
|
import AppLogger from "../client/appLogger";
|
|
import List from "./effects/List";
|
|
import Use from "./effects/Use";
|
|
import Buy from "./effects/Buy";
|
|
|
|
export default class Effects extends Command {
|
|
constructor() {
|
|
super();
|
|
|
|
this.CommandBuilder = new SlashCommandBuilder()
|
|
.setName("effects")
|
|
.setDescription("Effects")
|
|
.addSubcommand(x => x
|
|
.setName("list")
|
|
.setDescription("List all effects I have")
|
|
.addNumberOption(x => x
|
|
.setName("page")
|
|
.setDescription("The page number")
|
|
.setMinValue(1)))
|
|
.addSubcommand(x => x
|
|
.setName("use")
|
|
.setDescription("Use an effect in your inventory")
|
|
.addStringOption(y => y
|
|
.setName("id")
|
|
.setDescription("The effect id to use")
|
|
.setRequired(true)
|
|
.setChoices(EffectChoices)))
|
|
.addSubcommand(x => x
|
|
.setName("buy")
|
|
.setDescription("Buy more effects")
|
|
.addStringOption(y => y
|
|
.setName("id")
|
|
.setDescription("The effect id to buy")
|
|
.setRequired(true)
|
|
.setChoices(EffectChoices))
|
|
.addNumberOption(y => y
|
|
.setName("quantity")
|
|
.setDescription("The amount to buy")
|
|
.setMinValue(1)));
|
|
}
|
|
|
|
public override async execute(interaction: CommandInteraction) {
|
|
if (!interaction.isChatInputCommand()) return;
|
|
|
|
const subcommand = interaction.options.getSubcommand();
|
|
|
|
switch (subcommand) {
|
|
case "list":
|
|
await List(interaction);
|
|
break;
|
|
case "use":
|
|
await Use(interaction);
|
|
break;
|
|
case "buy":
|
|
await Buy(interaction);
|
|
break;
|
|
default:
|
|
AppLogger.LogError("Commands/Effects", `Invalid subcommand: ${subcommand}`);
|
|
}
|
|
}
|
|
}
|