错误:无法读取未定义的属性“标记”

时间:2019-06-22 13:52:34

标签: javascript node.js discord.js

尝试让我的机器人记录一条编辑消息,直到我更改为命令处理程序为止,这种方法都正常工作。

const { RichEmbed } = require('discord.js')

module.exports = async(oldMessage, newMessage) => { 

        if (oldMessage.content === newMessage.content) return;


        let editEmbed = new RichEmbed()
// Error occurs here:
        .setAuthor(`${oldMessage.author.tag}`, oldMessage.author.avatarURL)
        .setThumbnail(oldMessage.author.avatarURL)
        .setColor('RED')
        .setDescription("? **Message Edited**")
        .addField("Before Edit:", oldMessage.content, true)
        .addField("Edited Message:", newMessage.content, true)
        .addField("In Channel:", `<#${oldMessage.channel.id}>`, true)
        .setFooter("User ID: " + oldMessage.author.id)
        .setTimestamp()
        let sChannel = oldMessage.guild.channels.find(c => c.name === "logs?")
        sChannel.send(editEmbed);

}

我希望机器人记录已编辑的消息,但是在编辑消息时出现错误:

(node:11761) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'tag' of undefined

0 个答案:

没有答案