如何解决我可以通过哪个事件查看“MEMBER_DISCONNECT”审核日志?
这是代码:
client.on("voiceStateUpdate",async function(oldMember,newMember){
const guild = client.guilds.cache.get("586962324544553011");
const entry = await guild.fetchAuditLogs({type: 'MEMBER_disCONNECT'}).then(audit => audit.entries.first())
console.log(entry);
});
我的问题是,当每个用户离开房间时,最新的日志控制台会丢失。 即使此人未断开连接。
解决方法
您没有使用正确形式的代码。
您需要通过老会员和新会员要求语音更新!
当有人从(旧)语音通道(状态)断开连接时,旧成员正在使用。
为了显示您断开连接的成员,您必须使用:
(`${oldVoiceState.member} disconnected from ${oldVoiceState.channel.name}.`);
因此,正确的方法是先询问“已连接”成员,然后再询问“已断开连接”成员:
你可以试试这个:
client.on('voiceStateUpdate',(oldVoiceState,newVoiceState) => {
if (newVoiceState.channel) {
console.log(`${newVoiceState.member} connected to ${newVoiceState.channel.name}.`);
} else if (oldVoiceState.channel) {
console.log(`${oldVoiceState.member} disconnected from ${oldVoiceState.channel.name}.`);
}
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。