component.toJSON is not a function
This was gonna be a message in #djs-help-v14 but I ramble too much
I have a tendency to not use builders. maybe thats a flaw on my part, I don't know, but I always create embeds and commands in straight JSON. I assumed I could do the same with components V2, but when I try to send a simple container with a couple of text displays, I get this error:
I have some data I iterate over to produce the components, so I start out with an array,
components
and then I push my components to it as I iterate, here is an example of what I'm doing thats failing:
I then fetch a message in a channel, that was already sent using the flags for IsComponentsV2, and I supply components like so:
am I doing something wrong?
do I have to use builders instead?22 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!Try to use components: components @sludge
Might sound irrational but
Worth shot
there is zero reason why
components: components
would work if components
doesn't, but I tried it just so I can say I did and as expected, the error remainsHmm
well, I decided to mess with the builders to see if I could at least confirm that they work that way, and now I get a different error...
something is definitely not right but considering I am using a few builders for action rows and buttons elsewhere without issue, I struggle to see why these specifically don't work either
Holy fuck
In all honesty im impressed how it fucked up that bad
just wait for the fix for now
should be soon
it genuinely makes no sense. I got 'lucky' yesterday with another issue where it transpired there was a bug and it got fixed not long after, but this now just seems like a me issue
thats the thing, I feel like this has to be an issue with my code as opposed to a bug in djs
wait, I'll send u my sample
which works
and its raw JSON
that'd be awesome
toJSON was indeed missing
that should work
if not im out
oh and dont mind colors.normal, its just a number
so u can replace it
unfortunately, that gives me the same
component.toJSON
is not a function error. but Amgelo's response suggests that its a known issue being fixed - so the question is, how did it work for you š
I've also spent way too many hours this weekend already trying to work on thiswell
idrk
XD
it just worked
first try
and looks like that

maybe bc im using bun instead of node
ĀÆ\_(ć)_/ĀÆ
I guess. its 4am and I'm too tired to consider the implications of using a different runtime š“ I'll patiently wait for the patch and see whats up, I'm eager to replace a few of my embeds with containers, but it won't kill me to wait a few days if I need to before I mess around with it
wait hold on
i might have fucked up code
@sludge try this (edited version)
I already fixed your code when I tried it, it was missing some closing brackets, but the error is unrelated
welp idk then, wait for patch
hilariously, this was actually an issue with my code and I blame lack of sleep on it.
in case anyone cares, despite my local development environment being up to date, I forgot to update djs and its dependencies in my sort of mid staging area where I test using live data. this meant it had no idea what the new components even were š
all is working now as it should