Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

client.on('messageUpdate' ....) not working properly?

Tags:

discord.js

I'm trying to log when a user edits a message. Its not really working....

Here is my code:

client.on('messageUpdate', (oldMessage, newMessage) => {
    logMessageEdit(oldMessage, newMessage);
});

function logMessageEdit(oldMessage, newMessage) {

    if (!newMessage.guild.channels.find('name', "logs")) return;

    logChannel = newMessage.guild.channels.find('name', "logs");

    let logEmbed = new Discord.RichEmbed()
        .setAuthor(newMessage.author.tag, newMessage.author.avatarURL)
        .setDescription(`💬 | Meddelande redigerat i ${oldMessage.channel}.`)
        .addField("Innan", "test" + oldMessage.content)
        .addField("Efter", "test" + newMessage.content)
        .setTimestamp()
        .setFooter(newMessage.id)
        .setColor(greenColor);

    logChannel.send(logEmbed)
}

And here is what it results in:

like image 799
Scarmo Avatar asked Nov 28 '25 23:11

Scarmo


1 Answers

not too familiar with the client.on('messageUpdate') method but the bot is logging its own message sends, not just your messages. try updating your client.on('messageUpdate') method

client.on('messageUpdate', (oldMessage, newMessage) => {
    if(newMessage.author.id === client.user.id) return;
    logMessageEdit(oldMessage, newMessage);
});

if this doesn't work check for other calls of logMessageEdit such as in the client.on('message') event

like image 79
radiish Avatar answered Dec 02 '25 03:12

radiish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!