Fix embed not removing components after you run out

This commit is contained in:
Ethan Lane 2024-10-11 17:54:24 +01:00
parent 58e2fa3dfc
commit f7de57cf5d

View file

@ -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})`);
}
}
}