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,5 Replies
- 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 OPFirst of all, why not use buttons?
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.
How to go about writing this x amount of times depending on array length.
map over the array
do note an action row can have 5 components
but you can have 5 rows per message
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.