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:
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:
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.
As of October 7th, Discord has changed their API to require bots to declare gateway intents. Make sure your discord.py is updated to at least version 1.5 and enable the members intent:
import discord from discord.ext import commands intents = discord.Intents.default() intents.members = True bot = commands.Bot(command_prefix='!', intents=intents)