From 98bfd79a00861ce14afc8306a207f72b270121a6 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sun, 15 Sep 2024 15:11:24 +0100 Subject: [PATCH] Fix suggested changes --- src/buttonEvents/Sacrifice.ts | 4 ++-- src/commands/sacrifice.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/buttonEvents/Sacrifice.ts b/src/buttonEvents/Sacrifice.ts index 63c3971..463ca1f 100644 --- a/src/buttonEvents/Sacrifice.ts +++ b/src/buttonEvents/Sacrifice.ts @@ -23,7 +23,7 @@ export default class Sacrifice extends ButtonEvent { private async confirm(interaction: ButtonInteraction) { const userId = interaction.customId.split(" ")[2]; const cardNumber = interaction.customId.split(" ")[3]; - const quantity = Number(interaction.customId.split(" ")[4]) ?? 1; + const quantity = Number(interaction.customId.split(" ")[4]) || 1; if (userId != interaction.user.id) { await interaction.reply("Only the user who created this sacrifice can confirm it."); @@ -105,7 +105,7 @@ export default class Sacrifice extends ButtonEvent { private async cancel(interaction: ButtonInteraction) { const userId = interaction.customId.split(" ")[2]; const cardNumber = interaction.customId.split(" ")[3]; - const quantity = Number(interaction.customId.split(" ")[4]) ?? 1; + const quantity = Number(interaction.customId.split(" ")[4]) || 1; if (userId != interaction.user.id) { await interaction.reply("Only the user who created this sacrifice can cancel it."); diff --git a/src/commands/sacrifice.ts b/src/commands/sacrifice.ts index 40a0095..9683714 100644 --- a/src/commands/sacrifice.ts +++ b/src/commands/sacrifice.ts @@ -25,7 +25,9 @@ export default class Sacrifice extends Command { public override async execute(interaction: CommandInteraction): Promise { const cardnumber = interaction.options.get("cardnumber", true); - const quantity = interaction.options.get("quantity")?.value as number ?? 1; + const quantityInput = interaction.options.get("quantity")?.value ?? 1; + + const quantity = Number(quantityInput) || 1; const cardInInventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, cardnumber.value! as string);