Event : messageDelete gives a message object with content and author as null
I have a audit functionality for my bot. It sends a log item to the server when a message is deleted from the guild.
Everything used to run fine but since past few days,
every time a message is deleted and if that message was made before the current session of bot started (Heroku restarts dyno's everyday) the message object returned by the messageDelete event is totally waste.
Attached below
What I need is the content, author and the creation timestamp.
11 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
If the deleted message was made during the lifetime of the bot then it gets a correct object with author and content data. I understand that there is a caching of some sort but don't know much info. But this used to work when I made my logic initially and now stopped working all of a sudden. Idk what changed
Show ur client constructor
Thats expected
If the message wasnt cached. Some properties will be missing
And since discord doesnt send such data in that event and that its impossible to cache all messages, that output is expected
can i fetch/cache a particular message using its id ?
but when I initially made the logic for this they were sending me the required data. so what changed now
trying to figure out what went wrong and whats the way to work around this
No since the message doesnt exist
Nothing changed, you just enabled Message partial, so now you will receive events with partial messages
You can check if
message.partial
is true, and if so dont access those propertiesi honestly forgot why I turned those on but will it help if i removed partials.message from client
sounds good as a check
You just wont get the event for those messages
oof
thanks for info, idk if there is anything else i can do atm
As explained here its a limitation, you cant do much about it to get the data. Discord api doesnt send the information about the message so you can only rely on cache. But cache cant hold every message to ever exist in a server