Discord.py-rewrite - How to make the BOT self mute or self deaf in a voice channel?

有些话、适合烂在心里 提交于 2021-01-29 08:30:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!