Change a single button component detail (such as style) using update or something similar
I want to change a button's text and style upon an interaction submission. How can I do this?
15 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 OPDocumentation suggestion for @Swyftey:
:method: ButtonInteraction#update()
Updates the original message of the component on which the interaction was received on.
I wish that helped
that's what you need to use
and I am using that
But does it allow for a single button property change?
sure
Or does it change the entire message
I'll try it
it changes the message according to what you provide
simply provide your new components
I see, i'll give it a shot
But what is the best way to keep it clean
for example
Instead of repasting these with a different property or two
you could save the builder somewhere and when needed just clone it and update it according to what you need
or simply save the ButtonComponentData directly instead of a builder
Sorry, I'm very new to javascript, what exactly do you mean by "saving" it,
like put the data I want to set in a table?
storing it in a variable
Gotcha
I'll give it a shot, thanks
got it
I made separate functions with parameters to create each component