Whenever I tried to get a list of all the members in the current server, it only returns around 30 - 150 items. This only happens in the bigger servers.
Note: I've only tried this on selfbot.
Setup
import discord
from discord.ext import commands
prefix = '>>'
client = commands.Bot(command_prefix=prefix, self_bot=True)
# code ...
client.run(token, bot=False)
@client.event
async def on_message(message):
await client.process_commands(message)
@client.command()
async def list_members(ctx):
print(ctx.guild.member_count)
print(len(ctx.guild.members))
@client.event
async def on_message(message):
print(message.author.guild.member_count)
print(len(message.author.guild.members))
If there are 5000 members in the server.
5000
If there are 5000 members in the server
32
Discord does not dispatch the full member list to users anymore. Use a bot account with server members intents enabled.
@SebbyLaw I have the same question.can you tell me how to use server members intent?i can't find anything in docs
@SebbyLaw I have the same question.can you tell me how to use server members intent?i can't find anything in docs
https://blog.discord.com/the-future-of-bots-on-discord-4e6e050ab52e?gi=f32e9804962c
https://support.discord.com/hc/en-us/articles/360040720412
And it's on the Bot tab of your application
I know how to enable it.i was just thinking how the code is different than before in discord.py
It's not, the API either returns the result or it doesn't.
Hi, I don't know if it's related or not but I'm having also a different behavior on guild.members.
I tried the same simple script with 2 different version discord.py==1.3.4 and discord.py==1.5.0.
My dummy script to test it is the following one:
import discord
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
for m in client.guilds:
print(m)
print(m.members)
token = ".................."
client.run(token)
Ok now the results :
discord.py==1.3.4
[<Member id=1234 name='user1' discriminator='77]'....
I just sum up the result but it display the only server/guild on which I'm connected to and I get the list of all my users. It's the expected behavior.
discord.py==1.5.0
[<Member id=1235 name='mybotuser' discriminator='78]'....
In the list I have only one member. My bot itself.
In my output I can see I get the same server/guild name as well. But in this new version I don't have anymore others members listed.
@gaelL Your issue is caused by a lack of Intent subscription. As noted in the version 1.5 changelog "API Changes" section, you are required to pass the required Intents to your commands.Bot constructor to receive this information from the gateway.
This is not an issue with discord.py. For further help specific to using this library, you should join either the official discord.py server or the Discord API server, as the README recommends.
Most helpful comment
Discord does not dispatch the full member list to users anymore. Use a bot account with server members intents enabled.