Message cannot be edited
My code:
Versions
- discord.js:
14.17.3
- npm: 11.0.0
- Typescript: 5.2.6
- node: 22.13.0 LTS
I always get the error, that the edition of the panel failed. Does anyone have an idea what's wrong here?
-# This post is the continuation of https://github.com/discordjs/discord.js/issues/1070012 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 OPyeah, it's a Message object
uuuh, not now - I can show it later since I'm not at my pc.
okay, I now have the message object here. Got it with
inspect(panelData.where)
the client is just missing lol
I will try to replicate it with another bot.
nope, I didn't.
give me a moment, I'll try
well, I couldn't replicate it so I will try something else.
I now did a npm ci
. testing again...
well, client
wasn't found - it's undefined.
I will build in logging statements to trace where the client is lost.okay, as it turns out - the client is there after the fetch, and after the cache data gets initialized. (img 1)
But right when I retrieve it the next time, it's gone. (img 2)
Well, there's your issue then.
Object.assign
only copies the enumerable properties. <Message>.client is not enumerable:mdn: Object.assign()
The Object.assign() static method copies all enumerable own properties from one or more source objects to a target object. It returns the modified target object.
bruh...
but what can I do to fix this then?
Do not use it? Why do you even need to use it? From the looks of it, you are assigning it to an empty object, why not simply return it as is?
wdym?
oh, you mean I should just modify the original data instead of assigning it?
OR could I just do this?
I'm not sure what you are hoping to achieve by doing this
Object.assign({}, cachedData)
well... I also don't 😂 I may have forgot to make a comment why I I decided to do this back then haha
You can just do this then ^
okay, well I think I have to refactor this logic then xD
Thanks to y'all 😄
it was
it was logged as
Message { ... }
that's the funny part
uhm, this one was logged when the error was thrown when trying to edit the message.
Okay, I've now followed the advice and didn't create new instances every time. I think the issue is the NodeCache
library but I have to test that.
Update: HA. That's it. The client prop exceeds some limit in the caching library I guess. I will find a solution for by myself :)