如何获取所有语音频道中所有成员的数量 discord.py
How to get count of all members in all voice channels discord.py
我试过这样做
voicemembers_ = []
for v in ctx.guild.voice_channels:
voicemembers_.append(v.members)
voicemembers = voicemembers_
print(voicemembers)[0]
当想查找所有语音频道中的所有成员时
但我在终端中有 0
但在服务器中我有 10 多个成员
我也删除 [0] 并添加打印语句
找到这个
[[], [], [], [], [], [], [<Member id=481824139133321218 name='Не ебался 15 лет' discriminator='3598' bot=False nick='M1sT' guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>, <Member id=509012843329486860 name='Wolfemor' discriminator='2311' bot=False nick=None guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>, <Member id=530380443577483264 name='Arkul' discriminator='8151' bot=False nick=None guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>, <Member id=938530532541751476 name='Gluko' discriminator='1219' bot=False nick='Стримлер' guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>], [], [], [], [], [], [], [], [], [], [], [<Member id=287215916817842188 name='ap0sstal' discriminator='6526' bot=False nick='ap0sstal(p0n1m3(Серж))' guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>, <Member id=371699181741539329 name='ArtemKKKa' discriminator='5882' bot=False nick='666' guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>], [], [], [<Member id=286883614921326594 name='321' discriminator='9099' bot=False nick='Aizen' guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>, <Member id=485010706316656640 name='G1R0' discriminator='7773' bot=False nick=None guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>, <Member id=576859761434296344 name='Aleg(tilt)' discriminator='5562' bot=False nick=None guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>], []]
您可以使用 set
s,它速度快,易于计数,并且还会自动过滤掉任何重复的成员。
voice = set()
for v in ctx.guild.voice_channels:
for member in v.members:
voice.add(member.id)
然后,你可以通过len(voice)
得到总数。如果您想对其执行任何操作,也可以遍历所有成员。
我试过这样做
voicemembers_ = []
for v in ctx.guild.voice_channels:
voicemembers_.append(v.members)
voicemembers = voicemembers_
print(voicemembers)[0]
当想查找所有语音频道中的所有成员时 但我在终端中有 0 但在服务器中我有 10 多个成员 我也删除 [0] 并添加打印语句 找到这个
[[], [], [], [], [], [], [<Member id=481824139133321218 name='Не ебался 15 лет' discriminator='3598' bot=False nick='M1sT' guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>, <Member id=509012843329486860 name='Wolfemor' discriminator='2311' bot=False nick=None guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>, <Member id=530380443577483264 name='Arkul' discriminator='8151' bot=False nick=None guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>, <Member id=938530532541751476 name='Gluko' discriminator='1219' bot=False nick='Стримлер' guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>], [], [], [], [], [], [], [], [], [], [], [<Member id=287215916817842188 name='ap0sstal' discriminator='6526' bot=False nick='ap0sstal(p0n1m3(Серж))' guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>, <Member id=371699181741539329 name='ArtemKKKa' discriminator='5882' bot=False nick='666' guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>], [], [], [<Member id=286883614921326594 name='321' discriminator='9099' bot=False nick='Aizen' guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>, <Member id=485010706316656640 name='G1R0' discriminator='7773' bot=False nick=None guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>, <Member id=576859761434296344 name='Aleg(tilt)' discriminator='5562' bot=False nick=None guild=<Guild id=938540650209615953 name='Ghost Side' shard_id=0 chunked=True member_count=345>>], []]
您可以使用 set
s,它速度快,易于计数,并且还会自动过滤掉任何重复的成员。
voice = set()
for v in ctx.guild.voice_channels:
for member in v.members:
voice.add(member.id)
然后,你可以通过len(voice)
得到总数。如果您想对其执行任何操作,也可以遍历所有成员。