我可以检查语音通道中是否有用户?

时间:2018-12-23 13:56:51

标签: python discord discord.py

转译器会使英语显得不自然。

如果语音通道上没有用户,则程序将失败。

因此,我想检查语音通道上是否有用户,并且知道执行bool或其他重置类型的discord.py的功能。

elif message.content.startswith('>보이스'):

    tmp = str(message.author.display_name).split()
    tmp = tmp[2].split('(')


    if(len(tlst) >= 10 ):
        for i in range(0,len(lst)):
            if(tlst[4] == 3):
                print(i)
                vnum = tlst[i]
                vch = 'Duo_'+ str(vnum)
                print(vch)
                if(tmp[0] == lst[i]) == True:
                    embed = discord.Embed(title="이동완료!", color=0x00ff00)
                    await client.send_message(message.channel, embed=embed)
                    channel = discord.utils.find(lambda x: x.name == vch, message.server.channels)
                    await client.move_member(message.author , channel)

            elif(tlst[4] == 2):
                vnum = tlst[i]
                vch = 'Squad_'+ str(vnum)
                if(tmp[0] == lst[i]) == True:
                    embed = discord.Embed(title="이동완료!", color=0x00ff00)
                    await client.send_message(message.channel, embed=embed)
                    channel = discord.utils.find(lambda x: x.name == vch, message.server.channels)
                    await client.move_member(message.author , channel)
            else:
                embed = discord.Embed(title="띠용", description="팀 5는 보이스 기능이 없습니다.", color=0x00ff00)
                await client.send_message(message.channel, embed=embed)
    else:
        embed = discord.Embed(title="띠용", description="팀을 먼저 짜주세요~", color=0x00ff00)
        await client.send_message(message.channel, embed=embed)

1 个答案:

答案 0 :(得分:0)

您可以检查Channel.voice_members的长度,它将是频道中成员的列表。