#Unexpected MessageDelete events in discord.js v14.26.2 (no messages deleted)

28 messages · Page 1 of 1 (latest)

dry cradle
#

Hello!

Recently I noticed very strange behavior in my Discord bot. This issue did not occur before.
My bot suddenly starts triggering the MessageDelete event multiple times (sometimes 200 times in a few minutes), which causes errors in my handler. The strange part is that no messages are being deleted at all. The handler also cannot be the cause of the issue - it only sends an embed to a specific channel.

Important details:

  • The server is inactive (development server)
  • No users are deleting messages
  • No new messages are being sent (there are only messages sent by staff - approximately 20 messages for a day)
  • No channels or threads are being deleted
  • I only have one MessageDelete listener

I am aware that messages are not cached after a bot restart, but this is not the case here. The bot has already been running for some time and messages were loaded.
Despite that, the MessageDelete event fires unexpectedly and repeatedly.
I spent around an hour researching this, but couldn’t find a clear explanation.

Has anyone experienced something similar?

Thanks in advance!

autumn hatchBOT
split quest
dry cradle
split quest
#

can you share the event module?

dry cradle
frosty obsidian
dry cradle
dry cradle
#

The same code was working totally fine before

#

This code was working for 7 months and it suddenly changed about 2 weeks ago.

olive sorrel
#

Did you log the message to find out what messages and from where trigger it?

dry cradle
# olive sorrel Did you log the `message` to find out what messages and from where trigger it?

I added console.log yesterday because I hadn’t thought about it earlier. Now I see that the messageDelete event was not executed.

In my event I use try/catch to see what error occurs. It seems that message.author.tag was null or something like that. It was spamming every second, which was very strange.

I will send more information later because the problem did not occur during the night.

split quest
dry cradle
spring bluff
#

If the message is a partial, only id will be guaranteed to be present, rest of the props could be null. It'd be arguably better if you log it along with id, content and other identifying points

median kite
#

I've been having the same issue the past few days where we've been spammed with loads of delete events, asked in ddevs and were directed to this message #1130595287078015027 message from a few weeks ago

split quest
#

I wonder if we can make a check to see if the system deleted the messages rather than a user or bot in the guild?

olive sorrel
#

You can check if another user deleted the messages via AuditLog. But not if a bot, the author of the message or discord did.

dry cradle
#

So now I can see in my console that I had one error:

// From my console.log:
messageDelete fired {
  id: '1083458521976279113',
  channelId: '859839606714925117',
  guildId: '859755774048862253',
  partial: true,
  authorId: null,
  content: null
}
// Error:
TypeError: Cannot read properties of null (reading 'tag')
    at Object.execute (/home/minecraft/dc/Serwerowy/events/messageDelete.js:87:65)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Channel with id "859839606714925117" is disabled and empty. Only server staff have access.

dry cradle
#

Thanks everyone for your help!

olive sorrel
dry cradle
potent bone
#

Possibly someone who sent a message in that channel got banned from the server and messages deleted?

mild breach
#

In such cases discord sends bulk delete event(s)

dry cradle
dry cradle