Discord.py-rewrite-如何在语音通道中使BOT自静音或自聋?

问题描述:

我正在使用 discord.py-rewrite 制作Discord BOT,并专注于BOT的音乐"部分.我已多次检查API,但不知道如何在语音通道上使自静音或自聋(而不是使服务器静音或使服务器断音).任何人都知道我如何使静音的BOT静音或使自己聋吗?

I am making a Discord BOT using discord.py-rewrite and am focusing on the Music part of my BOT. I checked the API several times but I do not know how to make my self mute or self deaf on a voice channel (not server mute or server deafen). Anyone please know how I can self mute or self deaf my discord BOT?

该API似乎没有公开此功能,但是有

It looks like the API doesn't expose this functionality, but there is a method for doing this in the websocket code

@bot.command()
async def mute(ctx):
    voice_client = ctx.guild.voice_client
    if not voice_client:
        return
    channel = voice_client.channel
    await voice_client.main_ws.voice_state(ctx.guild.id, channel.id, self_mute=True)

我目前无法对此进行测试,因此它可能无法正常工作.还请记住,不能保证即使在次要版本之间,这样的内部方法也不会改变.

I can't test this at the moment, so it may not work. Keep in mind also that there is no guarantee that internal methods like this won't change even between minor versions.