问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/55904739/discord-py-rewrite-how-to-make-the-bot-self-mute-or-self-deaf-in-a-voice-chann