From 3c4f8b8099067f609c515be6777f2243a2ef05d9 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 11 Oct 2024 17:54:24 +0100 Subject: [PATCH] Fix embed not removing components after you run out --- src/buttonEvents/Multidrop.ts | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/buttonEvents/Multidrop.ts b/src/buttonEvents/Multidrop.ts index 314c6cf..e468068 100644 --- a/src/buttonEvents/Multidrop.ts +++ b/src/buttonEvents/Multidrop.ts @@ -75,7 +75,12 @@ export default class Multidrop extends ButtonEvent { .setDescription("Your multidrop has ran out! Please buy a new one!") .setColor(EmbedColours.Ok); - await interaction.update({ embeds: [ embed ]}); + await interaction.update({ + embeds: [ embed ], + attachments: [], + components: [], + }); + return; } @@ -92,7 +97,7 @@ export default class Multidrop extends ButtonEvent { await interaction.deferUpdate(); try { - const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", )); + const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", randomCard.card.path)); const imageFileName = randomCard.card.path.split("/").pop()!; const attachment = new AttachmentBuilder(image, { name: imageFileName }); @@ -104,7 +109,7 @@ export default class Multidrop extends ButtonEvent { const row = CardDropHelperMetadata.GenerateMultidropButtons(randomCard, cardsRemaining, interaction.user.id, cardsRemaining < 0); - await interaction.update({ + await interaction.editReply({ embeds: [ embed ], files: [ attachment ], components: [ row ], @@ -112,7 +117,7 @@ export default class Multidrop extends ButtonEvent { } catch (e) { AppLogger.LogError("Button/Multidrop/Keep", `Error sending next drop for card ${randomCard.card.id}: ${e}`); - await interaction.reply(`Unable to send next drop. Please try again, and report this if it keeps happening. (${randomCard.card.id})`); + await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. (${randomCard.card.id})`); } } @@ -160,7 +165,12 @@ export default class Multidrop extends ButtonEvent { .setDescription("Your multidrop has ran out! Please buy a new one!") .setColor(EmbedColours.Ok); - await interaction.update({ embeds: [ embed ]}); + await interaction.update({ + embeds: [ embed ], + attachments: [], + components: [], + }); + return; } @@ -169,7 +179,7 @@ export default class Multidrop extends ButtonEvent { cardsRemaining -= 1; if (!randomCard) { - AppLogger.LogWarn("Button/Multidrop/Keep", ErrorMessages.UnableToFetchCard); + AppLogger.LogWarn("Button/Multidrop/Sacrifice", ErrorMessages.UnableToFetchCard); await interaction.reply(ErrorMessages.UnableToFetchCard); return; } @@ -177,7 +187,7 @@ export default class Multidrop extends ButtonEvent { await interaction.deferUpdate(); try { - const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", )); + const image = readFileSync(path.join(process.env.DATA_DIR!, "cards", randomCard.card.path)); const imageFileName = randomCard.card.path.split("/").pop()!; const attachment = new AttachmentBuilder(image, { name: imageFileName }); @@ -189,15 +199,15 @@ export default class Multidrop extends ButtonEvent { const row = CardDropHelperMetadata.GenerateMultidropButtons(randomCard, cardsRemaining, interaction.user.id, cardsRemaining < 0); - await interaction.update({ + await interaction.editReply({ embeds: [ embed ], files: [ attachment ], components: [ row ], }); } catch (e) { - AppLogger.LogError("Button/Multidrop/Keep", `Error sending next drop for card ${randomCard.card.id}: ${e}`); + AppLogger.LogError("Button/Multidrop/Sacrifice", `Error sending next drop for card ${randomCard.card.id}: ${e}`); - await interaction.reply(`Unable to send next drop. Please try again, and report this if it keeps happening. (${randomCard.card.id})`); + await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. (${randomCard.card.id})`); } } } \ No newline at end of file