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
<ref *1> Message {
channelId: '1050491814500642887',
guildId: '1030918008559898726',
id: '1068670289535320104',
createdTimestamp: 1674861251959,
system: null,
type: null,
content: null,
author: null,
pinned: null,
tts: null,
nonce: null,
embeds: [],
components: [],
attachments: Collection(0) [Map] {},
stickers: Collection(0) [Map] {},
position: null,
editedTimestamp: null,
reactions: ReactionManager { message: [Circular *1] },
mentions: MessageMentions {
everyone: false,
users: Collection(0) [Map] {},
roles: Collection(0) [Map] {},
_members: null,
_channels: null,
_parsedUsers: null,
crosspostedChannels: Collection(0) [Map] {},
repliedUser: null
},
webhookId: null,
groupActivityApplication: null,
applicationId: null,
activity: null,
flags: MessageFlagsBitField { bitfield: 0 },
reference: null,
interaction: null
}
<ref *1> Message {
channelId: '1050491814500642887',
guildId: '1030918008559898726',
id: '1068670289535320104',
createdTimestamp: 1674861251959,
system: null,
type: null,
content: null,
author: null,
pinned: null,
tts: null,
nonce: null,
embeds: [],
components: [],
attachments: Collection(0) [Map] {},
stickers: Collection(0) [Map] {},
position: null,
editedTimestamp: null,
reactions: ReactionManager { message: [Circular *1] },
mentions: MessageMentions {
everyone: false,
users: Collection(0) [Map] {},
roles: Collection(0) [Map] {},
_members: null,
_channels: null,
_parsedUsers: null,
crosspostedChannels: Collection(0) [Map] {},
repliedUser: null
},
webhookId: null,
groupActivityApplication: null,
applicationId: null,
activity: null,
flags: MessageFlagsBitField { bitfield: 0 },
reference: null,
interaction: null
}
What I need is the content, author and the creation timestamp.
14 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Febkosq8
Febkosq82y ago
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
Harnes
Harnes2y ago
Show ur client constructor
Febkosq8
Febkosq82y ago
Parogo_72
Parogo_722y ago
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
Febkosq8
Febkosq82y ago
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
Parogo_72
Parogo_722y ago
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 properties
Febkosq8
Febkosq82y ago
i honestly forgot why I turned those on but will it help if i removed partials.message from client sounds good as a check
Parogo_72
Parogo_722y ago
You just wont get the event for those messages
Febkosq8
Febkosq82y ago
oof thanks for info, idk if there is anything else i can do atm
Parogo_72
Parogo_722y ago
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
Febkosq8
Febkosq82y ago
got it
Parogo_72
Parogo_722y ago
Unless you work for nasa and have a pc with best specs to ever be built lmao
Febkosq8
Febkosq82y ago
hehe i am running on eco heroku struggling as it is