Dynamic Amount of Message Reactions

I am creating a quiz command in my bot that reads information from an API I created. It formats the multiple choice question in an embed. Next, I would like to add reactions to the embed depending on the number of possible answers. Is the attached image for example, the top message would have reactions for A, B, C, D with the same emojis as the embed field value and the bottom message would have reactions for A, B. Currently drawing a blank on how to perform this. The guide (https://discordjs.guide/popular-topics/reactions.html#reacting-in-order) recommends calling message.react("EMOJI") multiple times, but I will be performing this dynamically. Thanks,
No description
5 Replies
d.js toolkit
d.js toolkit11mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
treble/luna
treble/luna11mo ago
First of all, why not use buttons?
datallboy
datallboyOP11mo ago
That's an option, yes. Largely the same "how to write this" problem as using reactions. Still need to dynamically write a certain amount of buttons depending on the length of array containing possible answers to a question.
const confirm = new ButtonBuilder()
.`setCustomId('confirm')
.setLabel('Confirm Ban')
.setStyle(ButtonStyle.Danger);`
const confirm = new ButtonBuilder()
.`setCustomId('confirm')
.setLabel('Confirm Ban')
.setStyle(ButtonStyle.Danger);`
How to go about writing this x amount of times depending on array length.
treble/luna
treble/luna11mo ago
map over the array do note an action row can have 5 components but you can have 5 rows per message
datallboy
datallboyOP11mo ago
Was looking at old guides and old docs. New docs says ActionRowBuilder.addComponent can take an array. The link to documentation on the guides website is pointing to old docs site, and I didn't catch that.
Want results from more Discord servers?
Add your server