Search code examples
node.jsdiscorddiscord.jsmessage

UnhandledPromiseRejectionWarning: ReferenceError: message is not defined


const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
    console.log(`Logged in as ${client.user.tag}!`);
});

client.on("messageUpdate", async (oldMessage, newMessage) => {
    var logchannel = client.channels.cache.get("736913251274719273");
    let logembed = new Discord.MessageEmbed()
        .setAuthor(message.author.tag, message.author.avatarURL)
        .setThumbnail(message.author.avatarURL)
        .setColor("RED")
        .setDescription(":wastebasket: Message Deleted")
        .addField("Message", message.content, true)
        .setTimestamp()

    logchannel.send(logembed)
})

client.login('token');

Solution

  • Your error is saying exactly what is your problem.

    message.author.tag
    

    message variable is used in several places of the function, but you didn't define the variable.