#Event : messageDelete gives a message object with content and author as null

24 messages · Page 1 of 1 (latest)

desert wave
#

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
}

What I need is the content, author and the creation timestamp.

twilit ice
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

desert wave
#

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

real frigate
#

Show ur client constructor

desert wave
bronze flame
#

Thats expected

bronze flame
#

And since discord doesnt send such data in that event and that its impossible to cache all messages, that output is expected

desert wave
#

can i fetch/cache a particular message using its id ?

desert wave
#

trying to figure out what went wrong and whats the way to work around this

bronze flame
bronze flame
#

You can check if message.partial is true, and if so dont access those properties

desert wave
bronze flame
desert wave
#

oof

#

thanks for info, idk if there is anything else i can do atm

bronze flame
bronze flame
#

Unless you work for nasa and have a pc with best specs to ever be built lmao

desert wave
#

hehe

#

i am running on eco heroku