首页 > 解决方案 > Discord.py 如何关闭不和谐机器人的麦克风状态(但不静音机器人)?

问题描述

我的问题是:在为机器人编写加入函数(下面的代码)之后,机器人可以成功加入语音通道,但它会显示它的麦克风已打开。(我没让他玩什么,只是加入语音频道功能)。
我的加入功能:

@Test011.command(pass_context=True)
async def join(ctx):
    global voice
    channel = ctx.message.author.voice.channel
    voice = get(Test011.voice_clients, guild=ctx.guild)

    if voice and voice.is_connected(): # User in voice channel & Bot also in voice channel somewhere else maybe.
        await voice.move_to(channel)
    else:  # bot is not in the channel, let it connect.
        voice = await channel.connect()
        print(f"The bot is connected to {channel}.")

    await ctx.send(f"Joined {channel}.")

截图上的麦克风(我没有让它播放任何东西):


机器人“Test001”打开了麦克风,因为它的头像周围有一个绿色的“环”。

不想让机器人静音,因为我试过了Guilds.change_voice_state

如果我不处理进一步的命令,我想让机器人加入,但不要打开麦克风。

任何帮助或建议表示赞赏!

标签: pythondiscord.py

解决方案


推荐阅读