vc 中的 Discord 静音机器人

问题描述 投票:0回答:1

当他加入 vc 时,我如何将机器人静音?我已经尝试过

await voice_client.guild.change_voice_state(mute=True)

但我必须获得更新版本的 dsicord.py。

我该怎么做?

python discord voice mute
1个回答
0
投票

您可以使用 VoiceClient 的 is_connected() 方法检查机器人是否连接到语音通道,然后使用 VoiceState 的静音属性使机器人静音或取消静音。 例子:

async def on_voice_state_update(member, before, after):
    if member == client.user and after.channel: # bot joined a channel
        voice_client = await after.channel.connect()
        await voice_client.guild.change_voice_state(mute=True)
    elif member == client.user and before.channel: # bot left a channel
        await before.channel.disconnect()
© www.soinside.com 2019 - 2024. All rights reserved.