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 toolkit8mo 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 docs8mo ago
Documentation suggestion for @Swyftey: :method: ButtonInteraction#update() Updates the original message of the component on which the interaction was received on.
Swyftey
SwyfteyOP8mo ago
I wish that helped
Amgelo
Amgelo8mo ago
that's what you need to use
Swyftey
SwyfteyOP8mo ago
and I am using that But does it allow for a single button property change?
Amgelo
Amgelo8mo ago
sure
Swyftey
SwyfteyOP8mo ago
Or does it change the entire message I'll try it
Amgelo
Amgelo8mo ago
it changes the message according to what you provide simply provide your new components
Swyftey
SwyfteyOP8mo ago
I see, i'll give it a shot But what is the best way to keep it clean for example
Swyftey
SwyfteyOP8mo ago
No description
Swyftey
SwyfteyOP8mo ago
Instead of repasting these with a different property or two
Amgelo
Amgelo8mo 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
SwyfteyOP8mo 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
Amgelo8mo ago
storing it in a variable
Swyftey
SwyfteyOP8mo 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