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