Implement buy subcommand
This commit is contained in:
parent
b2807adf4d
commit
38b0b8b301
2 changed files with 30 additions and 0 deletions
|
@ -1,4 +1,22 @@
|
||||||
import { CommandInteraction } from "discord.js";
|
import { CommandInteraction } from "discord.js";
|
||||||
|
import EffectHelper from "../../helpers/EffectHelper";
|
||||||
|
|
||||||
export default async function Buy(interaction: CommandInteraction) {
|
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 ],
|
||||||
|
});
|
||||||
}
|
}
|
12
tests/commands/effects/Buy.test.ts
Normal file
12
tests/commands/effects/Buy.test.ts
Normal 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");
|
||||||
|
});
|
Loading…
Reference in a new issue