From a1c9f9f32e1ac6ff03a11821a16f2d851786de8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Gro=C3=9F?= Date: Wed, 5 Apr 2023 16:47:13 +0200 Subject: [PATCH] ReplyUtils: Make component recreation compatible with multi-row components --- commands/drop.js | 10 +++++----- util/reply.js | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/commands/drop.js b/commands/drop.js index 1ca576a..2fb8093 100644 --- a/commands/drop.js +++ b/commands/drop.js @@ -191,12 +191,12 @@ module.exports = { }); 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, card: cards[cardId] }); - let newRow = ReplyUtils.recreateComponents(i.message.components); - newRow.components[cardId].setLabel("Claimed"); - newRow.components[cardId].setStyle(ButtonStyle.Success); - newRow.components[cardId].setDisabled(true); + let newComponents = ReplyUtils.recreateComponents(i.message.components); + newComponents[0].components[cardId].setLabel("Claimed"); + newComponents[0].components[cardId].setStyle(ButtonStyle.Success); + newComponents[0].components[cardId].setDisabled(true); //let deckImage = await Rendering.renderCardStack(cards); - message.edit({ components: [newRow] }); + message.edit({ components: newComponents }); } }); diff --git a/util/reply.js b/util/reply.js index 2ba3be7..64cbc95 100644 --- a/util/reply.js +++ b/util/reply.js @@ -4,6 +4,7 @@ module.exports = { name: "ReplyUtils", recreateComponents: function(components) { console.log("Recreating components"); + let newComponents = []; for (let i = 0; i < components.length; i++) { let row = new ActionRowBuilder(); for (let j = 0; j < components[i].components.length; j++) { @@ -21,7 +22,8 @@ module.exports = { } row.addComponents(button); } - return row; + newComponents.push(row); } + return newComponents; }, }