ReplyUtils: Make component recreation compatible with multi-row components
This commit is contained in:
@@ -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 });
|
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] });
|
collectionReplies.push({ ref: reply, characterName: character.name, card: cards[cardId] });
|
||||||
let newRow = ReplyUtils.recreateComponents(i.message.components);
|
let newComponents = ReplyUtils.recreateComponents(i.message.components);
|
||||||
newRow.components[cardId].setLabel("Claimed");
|
newComponents[0].components[cardId].setLabel("Claimed");
|
||||||
newRow.components[cardId].setStyle(ButtonStyle.Success);
|
newComponents[0].components[cardId].setStyle(ButtonStyle.Success);
|
||||||
newRow.components[cardId].setDisabled(true);
|
newComponents[0].components[cardId].setDisabled(true);
|
||||||
//let deckImage = await Rendering.renderCardStack(cards);
|
//let deckImage = await Rendering.renderCardStack(cards);
|
||||||
message.edit({ components: [newRow] });
|
message.edit({ components: newComponents });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ module.exports = {
|
|||||||
name: "ReplyUtils",
|
name: "ReplyUtils",
|
||||||
recreateComponents: function(components) {
|
recreateComponents: function(components) {
|
||||||
console.log("Recreating components");
|
console.log("Recreating components");
|
||||||
|
let newComponents = [];
|
||||||
for (let i = 0; i < components.length; i++) {
|
for (let i = 0; i < components.length; i++) {
|
||||||
let row = new ActionRowBuilder();
|
let row = new ActionRowBuilder();
|
||||||
for (let j = 0; j < components[i].components.length; j++) {
|
for (let j = 0; j < components[i].components.length; j++) {
|
||||||
@@ -21,7 +22,8 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
row.addComponents(button);
|
row.addComponents(button);
|
||||||
}
|
}
|
||||||
return row;
|
newComponents.push(row);
|
||||||
}
|
}
|
||||||
|
return newComponents;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user