[英]Attempting to get message pin audit logs on discord.js does not return the log for the most recently pinned message
所以我试图让我的机器人记录消息固定和取消固定。 这段代码过去一直有效,但现在由于某种原因,获取的日志没有针对其固定触发了 messageUpdate 事件的消息的条目。
const fetchedLogs = await oldMessage.guild.fetchAuditLogs({
type: 'MESSAGE_PIN',
});
const pinLog = fetchedLogs.entries.filter(f => f.extra.messageID == oldMessage.id).first();
const { executor } = pinLog;
显示的错误是:
Uncaught Promise Rejection TypeError: Cannot destructure property 'executor' of 'pinLog' as it is undefined.
这个确切的代码直到最近才有效。
我尝试过的事情:
从 v13 开始,id 属性的命名已更改(如指南中所示)。 而不是.xxxID
,现在是.xxxId
// messageID -> messageId
const pinLog = fetchedLogs.entries.filter(f => f.extra.messageId == oldMessage.id).first()
还要注意, .find()
更适合这个,因为它得到第一个 object 匹配回调
const pinLog = fetchedLogs.entries.find(f => f.extra.messageId == oldMessage.id)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.