每当他们使用Discord.jS在语音通道中使自己静音时,我想获得一个人的User对象。
示例:
if (somebody has muted themselves)
{
const member = user.id;
}
答案 0 :(得分:1)
您可以收听Client#voiceStateUpdate
事件。每当语音状态更新时,它将触发。 (这包括成员使自己静音的时间。)
VoiceState
具有一个名为selfMute
(布尔值)的属性,该属性指示成员是否使自己静音。您可以使用serverMute
查看该成员是否被服务器静音。
client.on("voiceStateUpdate", (oldVoiceState, newVoiceState) => {
if (oldVoiceState.selfMute !== newVoiceState.selfMute) {
if (newVoiceState.selfMute) {
console.log(`${newVoiceState.member.user.tag} muted themselves!`);
};
};
});