Closed LostXOR closed 2 years ago
As I understand from the expected result, you want to get the len()
- aka the count - of every guild's members that the account is in. You can simply avoid fetching members. Just iterate over the guilds and use len()
over .members
.
Example:
for guild in bot.guilds:
print(len(guild.members))
Don't do this, use guild.member_count
when you request it several times it works
when you request it several times it works
Don't do that either 🙃
As I understand from the expected result, you want to get the
len()
- aka the count - of every guild's members that the account is in. You can simply avoid fetching members. Just iterate over the guilds and uselen()
over.members
. Example:for guild in bot.guilds: print(len(guild.members))
I want to get every user in the guild, not the number of users. The length is just how I'm checking if it was successful.
Hi! if you want to get all members of a guild, you could use something like this:
import discord
client = discord.Client()
@client.event
async def on_ready():
guild1 = bot.get_guild(ENTER_GUILD_ID)
for member in guild1.members:
print(member.name) # or some other Stuff
client.run("token")
I hope I didn't screw it up, I couldn't debug this since I'm on a mobile.
The last code works only if the number of members is less than 1k members. Over it doesn't scrape anything
I have the same problem with guild.fetch_members(force_scraping = True)
, and In addition to this when I use ctx.guild
as Guild to fetching, it returns ClientException: Fetching members failed
error
The logs should provide more information.
The logs should provide more information.
How to provide more information?
Sending the logs (please set to debug log level).
Sending the logs (please set to debug log level).
How can I do that?
Sending the logs (please set to debug log level).
How can I do that?
You... log to a file and attach it?
I'm completely unable to reproduce this and nobody has provided any reproduction code that doesn't have basic errors. Closing for now.
I'm completely unable to reproduce this and nobody has provided any reproduction code that doesn't have basic errors. Closing for now.
I seem to get discord.errors.ClientException: Fetching members failed
.
Code: `import logging logging.basicConfig(filename='example.log', encoding='utf-8', level=logging.DEBUG)
guild1 = client.get_guild(728174834760155137)
print(guild1)
members = await guild1.fetch_members()
print(len(members))
#print(str(lenmembersfetched)+' members fetched from ' + serverNames[guild_id])
for member in guild1.members:
userList.append(member.id)
print(member.id)
`
Log is attached. example.log
@dolfies
Summary
guild.fetch_members() returns an empty list when scraping is used.
Reproduction Steps
Use
guild.fetch_members()
on any guild where the user does not have mod permissions, or useguild.fetch_members(force_scraping = True)
on any guild. Even if the guild has members it will return an empty list. This happens even withguild.fetch_members(channels = guild.channels)
.Code
Expected Results
The code prints how many members are in each guild the user is in.
Actual Results
The code prints 0 for every guild.
System Information
Checklist
Additional Information
No response