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?
No description
15 Replies
d.js toolkit
d.js toolkit9mo 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
d.js docs
d.js docs9mo ago
Documentation suggestion for @Swyftey: :method: ButtonInteraction#update() Updates the original message of the component on which the interaction was received on.
Swyftey
SwyfteyOP9mo ago
I wish that helped
Amgelo
Amgelo9mo ago
that's what you need to use
Swyftey
SwyfteyOP9mo ago
and I am using that But does it allow for a single button property change?
Amgelo
Amgelo9mo ago
sure
Swyftey
SwyfteyOP9mo ago
Or does it change the entire message I'll try it
Amgelo
Amgelo9mo ago
it changes the message according to what you provide simply provide your new components
Swyftey
SwyfteyOP9mo ago
I see, i'll give it a shot But what is the best way to keep it clean for example
Swyftey
SwyfteyOP9mo ago
No description
Swyftey
SwyfteyOP9mo ago
Instead of repasting these with a different property or two
Amgelo
Amgelo9mo ago
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
Swyftey
SwyfteyOP9mo ago
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?
Amgelo
Amgelo9mo ago
storing it in a variable
Swyftey
SwyfteyOP9mo ago
Gotcha I'll give it a shot, thanks got it I made separate functions with parameters to create each component
Want results from more Discord servers?
Add your server