discord.py-self: guild.fetch_members() returns an empty list when scraping is used

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 use guild.fetch_members(force_scraping = True) on any guild. Even if the guild has members it will return an empty list. This happens even with guild.fetch_members(channels = guild.channels).

Code

import discord

client = discord.Client()

@client.event
async def on_ready():
    for guild in client.guilds:
        members = await guild.fetch_members(channels = guild.channels, force_scraping = True)
        print(len(members))

client.run("token")

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

  • Python v3.9.12-final
  • discord.py-self v2.0.0-alpha
    • discord.py-self pkg_resources: v2.0.0a2
  • aiohttp v3.7.4.post0
  • system info: Linux 4.15.0-175-generic #184-Ubuntu SMP Thu Mar 24 17:48:36 UTC 2022

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn’t visible in the code).

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 15 (6 by maintainers)

Most upvoted comments

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