我正在关注modlog频道上的教程,但我一直收到此错误。
(node:4468) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'guild' of undefined
这是代码
client.on('messageDelete', async (client, message) => {
if (message.partial) await message.fetch();
let modlog = db.get(`moderation.${message.guild.id}.modlog`);
if (!modlog) return;
if (message.channel.id === modlog.channel) return;
let toggle = modlog.toggle;
if (!toggle || toggle == null || toggle == false) return;
const embed = new MessageEmbed()
.setTitle("Message Deleted")
.setDescription(`Message deleted in <#${message.channel.id}> by **${message.author.tag}** \n> ${message.content}`)
return message.guild.channels.cache.get(modlog.channel).send(embed);
})
答案 0 :(得分:2)
Client#messageDelete
事件只为您提供Message
作为第一个参数。第二个参数是未定义的。
client.on("messageDelete", async (message) => {
if (message.partial) await message.fetch();
let modlog = db.get(`moderation.${message.guild.id}.modlog`);
if (!modlog) return;
if (message.channel.id === modlog.channel) return;
let toggle = modlog.toggle;
if (!toggle || toggle == null || toggle == false) return;
const embed = new MessageEmbed().setTitle("Message Deleted").setDescription(`Message deleted in <#${message.channel.id}> by **${message.author.tag}** \n> ${message.content}`);
return message.guild.channels.cache.get(modlog.channel).send(embed);
});