diff --git a/src/commands/effects/Buy.ts b/src/commands/effects/Buy.ts index e26b585..3ebf587 100644 --- a/src/commands/effects/Buy.ts +++ b/src/commands/effects/Buy.ts @@ -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 ], + }); } \ No newline at end of file diff --git a/tests/commands/effects/Buy.test.ts b/tests/commands/effects/Buy.test.ts new file mode 100644 index 0000000..8ae5cf3 --- /dev/null +++ b/tests/commands/effects/Buy.test.ts @@ -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"); +});