【问题标题】:get id of self muted person in voice channel获取语​​音通道中自闭者的 ID
【发布时间】:2020-09-12 21:15:26
【问题描述】:

每当某人使用 Discord.jS 在语音频道中将自己静音时,我都想获取该人的 User 对象。

例子:

if (somebody has muted themselves)
{
   const member = user.id;
}

【问题讨论】:

    标签: node.js discord discord.js


    【解决方案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!`);
            };
        };
    });
    

    【讨论】:

      猜你喜欢
      • 2020-12-24
      • 2021-03-11
      • 2018-09-24
      • 2020-09-16
      • 2022-07-06
      • 2019-11-24
      • 2022-01-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多