#Issue with messageDelete event

3 messages · Page 1 of 1 (latest)

modern temple
#

messageDelete event doesn't trigger when I delete a message that was sent before the bot went online.

e.g. if you run the bot then send a message and delete it the event will work normally but if you send the message before running the bot then the event won't work

I use a normal code to test it

const { Client, Intents } = require('discord.js');

const client = new Client({
  intents: [
    Intents.FLAGS.GUILDS,
    Intents.FLAGS.GUILD_MESSAGES
  ]
});

client.on('messageDelete', message => {
  console.log(message.content);
});
gritty eagle
#

Because the bot doesn’t have the content cached. It has no chance to show you the content. You could put MESSAGE partial in your constructor, then you‘d get the event even for those messages, but it won’t have any content, only the messageId and channel/guild information

#

Or fetch relevant messages you need to know about before they get deleted… but be aware of ratelimits in those cases