Implement buy subcommand

This commit is contained in:
Ethan Lane 2025-02-09 18:56:15 +00:00
parent b2807adf4d
commit 38b0b8b301
2 changed files with 30 additions and 0 deletions

View file

@ -1,4 +1,22 @@
import { CommandInteraction } from "discord.js";
import EffectHelper from "../../helpers/EffectHelper";
export default async function Buy(interaction: CommandInteraction) {
const id = interaction.options.get("id", true).value!;
const quantity = interaction.options.get("quantity")?.value ?? 1;
const idValue = id.toString();
const quantityValue = Number(quantity);
const result = await EffectHelper.GenerateEffectBuyEmbed(interaction.user.id, idValue, quantityValue, false);
if (typeof result == "string") {
await interaction.reply(result);
return;
}
await interaction.reply({
embeds: [ result.embed ],
components: [ result.row ],
});
}

View file

@ -0,0 +1,12 @@
import Buy from "../../../src/commands/effects/Buy";
import EffectHelper from "../../../src/helpers/EffectHelper";
jest.mock("../../../src/helpers/EffectHelper");
describe("Buy", () => {
test.todo("GIVEN result returns a string, EXPECT interaction replied with string");
test.todo("GIVEN result returns an embed, EXPECT interaction replied with embed and row");
test.todo("GIVEN quantity option is not supplied, EXPECT quantity to default to 1");
});