#messageUpdate being run on a link

3 messages · Page 1 of 1 (latest)

crimson gull
#

Hi all, I have a messageUpdate listener, however it gets run everytime a link is sent in a channel. I think this is because the link preview (embed) is being added a bit later than the link and triggers a messageUpdate. Does anybody know how to make this stop? Below is the code:

client.on('messageUpdate', async (oldMessage, newMessage) => {
    if (oldMessage.author?.bot) return;
    if (config.channels.ignore.includes(oldMessage.channel.parentId) || config.channels.ignore.includes(oldMessage.channel.id)) return;


    let embed = new EmbedBuilder()
        .setTitle('Message Edited')
        .setColor([255, 165, 0])
        .addFields(
            { name: 'Author', value: `${oldMessage.author}`, inline: true },
            { name: 'Channel', value: `${oldMessage.channel}`, inline: true },
            { name: 'Old Content', value: oldMessage.content, inline: false },
            { name: 'Edited Content', value: newMessage.content, inline: false },
        )

    let serverLogChannel = client.guilds.cache.get(config.guildId).channels.cache.get(config.channels.serverLogs)
    serverLogChannel.send({
        embeds: [embed]
    })
})```

Thanks!
lament sinewBOT
#

• 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.

crimson gull
#

djs version 14.0.3
node version 16.14.0