Python 使bot断开连接(如果是';她独自在一个语音频道里不和谐

Python 使bot断开连接(如果是';她独自在一个语音频道里不和谐,python,python-3.x,discord,discord.py,Python,Python 3.x,Discord,Discord.py,如果机器人单独在语音频道上,有没有办法断开它的连接?每次有人离开vc或类似的工作时,是否会触发任何事件?我不太了解语音频道,但你可以检查成员数量,并像这样进行任务循环 async def check(): # define the voice channel member_count = len(voice_channel.members) if member_count == 1: # leave the channel await asynci

如果机器人单独在语音频道上,有没有办法断开它的连接?每次有人离开vc或类似的工作时,是否会触发任何事件?

我不太了解语音频道,但你可以检查成员数量,并像这样进行任务循环

async def check():
    # define the voice channel
    member_count = len(voice_channel.members)
    if member_count == 1:
        # leave the channel
    await asyncio.sleep(30)
client.loop.create_task(check())

可能会有更好的答案,但这也可以解决您的问题。

我不太了解语音频道,但您可以使用检查成员数量,并创建一个任务循环,如

async def check():
    # define the voice channel
    member_count = len(voice_channel.members)
    if member_count == 1:
        # leave the channel
    await asyncio.sleep(30)
client.loop.create_task(check())
也许有更好的答案,但这也可以解决你的问题