From e1f1ad79e8b6229d6d472df31be8c011ac60df45 Mon Sep 17 00:00:00 2001 From: Minzkraut Date: Wed, 31 Aug 2022 23:57:06 +0200 Subject: [PATCH] Drop: Update claim messages to show the character name once cards are revealed --- commands/drop.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/commands/drop.js b/commands/drop.js index c916323..ce16cc8 100644 --- a/commands/drop.js +++ b/commands/drop.js @@ -64,7 +64,8 @@ module.exports = { const filter = m => m.author.id === interaction.user.id; const collector = message.createMessageComponentCollector({ componentType: ComponentType.Button, time: 25000 }); - + + let collectionReplies = []; collector.on('collect', async i => { let cardId = i.customId.split("-")[1]; if (await cards[cardId].userId) { i.reply({ content: "This card has already been claimed!", ephemeral: true }); return; } @@ -92,7 +93,8 @@ module.exports = { id: cards[cardId].characterId } }); - i.reply({ content: `${i.user} (${claimUser.id}) claimed a card! [${cards[cardId].identifier}]`, ephemeral: false }); + let reply = await i.reply({ content: `${i.user} (${claimUser.id}) claimed a card! [${cards[cardId].identifier}]`, ephemeral: false, fetchReply: true }); + collectionReplies.push({ ref: reply, characterName: character.name }); let newRow = ReplyUtils.recreateComponents(i.message.components); newRow.components[cardId].setLabel("Claimed"); newRow.components[cardId].setStyle(ButtonStyle.Success); @@ -104,7 +106,10 @@ module.exports = { collector.on('end', async collected => { let dropHistory = {}; - + for (reply of collectionReplies) { + //TODO: strings shouldn't be inlined. Needs refactoring + reply.ref.edit({ content: `${reply.ref.content.replace('a card', reply.characterName)}` }); + } console.log(`Collected ${collected.size} interactions.`); for (let card of cards) { if (!card.userId) {