Create ability to drop multiple cards in a row #376

Merged
Vylpes merged 8 commits from feature/262-multidrop into develop 2024-10-12 17:30:20 +01:00
Showing only changes of commit 3c4f8b8099 - Show all commits

View file

@ -75,7 +75,12 @@ export default class Multidrop extends ButtonEvent {
.setDescription("Your multidrop has ran out! Please buy a new one!") .setDescription("Your multidrop has ran out! Please buy a new one!")
.setColor(EmbedColours.Ok); .setColor(EmbedColours.Ok);
await interaction.update({ embeds: [ embed ]}); await interaction.update({
embeds: [ embed ],
attachments: [],
components: [],
});
return; return;
} }
@ -92,7 +97,7 @@ export default class Multidrop extends ButtonEvent {
await interaction.deferUpdate(); await interaction.deferUpdate();
try { 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 imageFileName = randomCard.card.path.split("/").pop()!;
const attachment = new AttachmentBuilder(image, { name: imageFileName }); 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); const row = CardDropHelperMetadata.GenerateMultidropButtons(randomCard, cardsRemaining, interaction.user.id, cardsRemaining < 0);
await interaction.update({ await interaction.editReply({
embeds: [ embed ], embeds: [ embed ],
files: [ attachment ], files: [ attachment ],
components: [ row ], components: [ row ],
@ -112,7 +117,7 @@ export default class Multidrop extends ButtonEvent {
} catch (e) { } catch (e) {
AppLogger.LogError("Button/Multidrop/Keep", `Error sending next drop for card ${randomCard.card.id}: ${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!") .setDescription("Your multidrop has ran out! Please buy a new one!")
.setColor(EmbedColours.Ok); .setColor(EmbedColours.Ok);
await interaction.update({ embeds: [ embed ]}); await interaction.update({
embeds: [ embed ],
attachments: [],
components: [],
});
return; return;
} }
@ -169,7 +179,7 @@ export default class Multidrop extends ButtonEvent {
cardsRemaining -= 1; cardsRemaining -= 1;
if (!randomCard) { if (!randomCard) {
AppLogger.LogWarn("Button/Multidrop/Keep", ErrorMessages.UnableToFetchCard); AppLogger.LogWarn("Button/Multidrop/Sacrifice", ErrorMessages.UnableToFetchCard);
await interaction.reply(ErrorMessages.UnableToFetchCard); await interaction.reply(ErrorMessages.UnableToFetchCard);
return; return;
} }
@ -177,7 +187,7 @@ export default class Multidrop extends ButtonEvent {
await interaction.deferUpdate(); await interaction.deferUpdate();
try { 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 imageFileName = randomCard.card.path.split("/").pop()!;
const attachment = new AttachmentBuilder(image, { name: imageFileName }); 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); const row = CardDropHelperMetadata.GenerateMultidropButtons(randomCard, cardsRemaining, interaction.user.id, cardsRemaining < 0);
await interaction.update({ await interaction.editReply({
embeds: [ embed ], embeds: [ embed ],
files: [ attachment ], files: [ attachment ],
components: [ row ], components: [ row ],
}); });
} catch (e) { } 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})`);
} }
} }
} }