Execute command on button interaction
For example, if I have a command that rolls a dice and takes the number of sides as an optional input, would it be possible to setup two buttons to run the command again? One button would be to roll again with the same number of sides and the second would be to roll a d6
3 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!In the slash command response, send result message with buttons attached
Create collector on message for buttons
On button interaction in the collector, edit original message or send a new one with the new dice rolls
I see, so all the code would be done inside the slash command response? I have some slight concerns about stacking all the recursive calls. There's no way to pass the interaction foward to something else?
I guess in that case, I can pass the interaction to the function and then the function can also create its own button if I wanted to create another set of buttons to rerun the game. Not sure if thats what you were saying, but that does seem like itll work