Please Explain This Stupidity - ButtonComponent and modifying existing buttons (on messages)
Hello. I use typescript
I would like to know... Why Can't I Simply Modify An Existing Message's Buttons? As shown in the picture attached, I am trying to disable a button after it has been clicked in a tic-tac-toe game. However,
const button
returns a ButtonComponent, which doesn't allow me to disabled the button due to 1. no .setDisabled()
function and 2. the .disabled property being read-only. Thus, leaving me only with the option of creating a whole new god damn actionrow just to modify a single button, which is very frustrating. Is there way to convert the ButtonComponent into a builder instead or...? I'm so lost
This is not a typescript issue; I used ts ignore on it and it stilled errored saying the disabled value is a getter
Would someone please assist me because This Isn't The First Time I've Came Across This Exact Scenario
Everything else works fine... For Now.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!
- ✅
Marked as resolved by OPThis is by design, a ButtonComponent is the data you received from Discord. It's part of your message cache, and you should not be attempting to modify it directly. That would break your internal cached state.
To make a new modifiable button builder, you can use
ButtonBuilder.from(<ButtonComponent>)
Sorry for the late response, thank you for letting me know this
Been a while since I've used discord.js (or coded period) so this was kind of a surprise to me