嘿,我正在检查一个特定的用户是否在一个语音频道。在一个频道中检索用户是可行的,但我无法用“if”来确定其中是否有某个id。我从Python列表中获取用户id。我不知道该怎么办请帮忙:)
@client.command()
async def foo(ctx):
t = len(memberlist)
countermem = 0
for _ in range(t):
voice_channel = client.get_channel(802195467278352407)
voice_state = ctx.member.voice
ids = voice_channel.voice_states.keys()
userid = memberlist[(countermem)]
channelid = discord.VoiceChannel
voice_state = userid.member.voice
if voice_state is None:
print ("Somesssssssssssng")
print(channelid)
print ("Some thing")
id = memberlist[(countermem)]
print(id)
fullstring = voice_channel.voice_states.keys()
substring = "700388090631421982"
if memberlist[(countermem)] in voice_channel.voice_states.keys():
print("is in a channel")
if id in voicestats:
voicestats[id] += 10
_savestats()
print("it worked")
else:
print("was not in stats file")
voicestats[id] = 10
_savestats()
else:
print("not in a channel")
countermem += 1
VoiceChannel
具有属性members
,它返回连接到语音频道的成员列表,您可以使用Guild.get_member
获取discord.Member
实例,并将其与in
关键字(如果成员在语音频道中)进行比较参考资料:
相关问题 更多 >
编程相关推荐