所以最近我很困惑,如何将更新其语音状态(如静音/震耳欲聋(的成员记录到文本通道中。我已经记录了成员在语音频道之间加入/离开/移动时的日志。但是我不知道如何更新有关自静音等的语音状态。有人可以告诉我该怎么做吗?
阅读文档有这个函数:
voiceStateUpdate
它说:每当成员更改语音状态时发出 - 例如加入/离开频道,静音/取消静音。
并接受以下参数:
oldState VoiceState The voice state before the update
newState VoiceState The voice state after the update
您可以通过以下方式检测:
client.on('voiceStateUpdate', (oldState,newState) => {
if(oldState.selfMute === true && newState.selfMute === false)
console.log("unmuted")
if(oldState.selfMute === false && newState.selfMute === true)
console.log("muted")
if(oldState.selfDeaf === true && newState.selfDeaf === false)
console.log("undeaf")
if(oldState.selfDeaf === false && newState.selfDeaf === true)
console.log("deaf")
});