Any time I try to use VoiceChannel.members or Guild.members it does not give me a full list of applicable members. I'm grabbing both the VoiceChannel and the Guild from the context in a text command like this:
@bot.command(name='followme')
async def follow_me(ctx):
if ctx.author.voice != None:
guild = ctx.guild
tracking = ctx.author
channel = tracking.voice.channel
Later on I've tried to use the channel like this:
for member in channel.members:
if member.voice.mute != True:
await member.edit(mute=True)
However, it's only finding my user despite having another user in the channel.
I found that the only way I could get an accurate representation of members in the channel is using:
channel.voice_states.keys()
Using voice_states, I can get an accurate list of members, but only by their IDs when I still need to manipulate the member itself.
So I tried this:
for key in channel.voice_states.keys():
member = guild.get_member(key)
if member.voice.mute != True:
await member.edit(mute=True)
However, the guild isn't pulling the right set of users and despite verifying all the IDs were correct, guild.members is also not working appropriately.
Any input on how to get this working properly would be greatly appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…