dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
717 stars 163 forks source link

`guild.members` does not work properly #90

Closed pptx704 closed 3 years ago

pptx704 commented 3 years ago

Summary

When I tried guild.members on a server of around 78k members and having 15k users online on average, only 100 members are returned.

Code

import discord
from os import path
from time import perf_counter

variables = {
    'guild': 1234567890,
    'token': "abcdefghijklmnop"
}

class MyClient(discord.Client):
    async def on_ready(self):
        print("Logged in as", self.user)
        guild = self.get_guild(variables["guild"])
        start = perf_counter()
        with open(path.join(path.dirname(__file__), 'tempfile.txt'), 'w', encoding="utf-8") as file:
            file.write(f"{len(guild.members)}\n")
            print(f"{len(guild.members)}")
            for member in guild.members:
                file.write(f"{member.name}#{member.discriminator}, {member.id}\n")
            file.write(f"{guild.members}\n")
            print(f"{perf_counter()- start}")

client = MyClient()
client.run(variables['token'])

Expected Results

Maybe the list of 15k users who are online.

Actual Results

Prints
Logged in as User#1234
99
0.00043590000000026663

Checklist

caiocinel commented 3 years ago

In order to acquire all members, it is necessary to use a guild.subscribe(), only after that all information will be displayed. This function can take a long time to complete.

Em sex., 24 de set. de 2021 às 04:17, Rafeed @.***> escreveu:

Summary When I tried guild.members on a server of around 78k members and having 15k users online on average, only 100 members are returned. Code Relevant code that shows the bug.

import discordfrom os import pathfrom time import perf_counter variables = { 'guild': 1234567890, 'token': "abcdefghijklmnop" } class MyClient(discord.Client): async def on_ready(self): print("Logged in as", self.user) guild = self.get_guild(variables["guild"]) start = perf_counter() with open(path.join(path.dirname(file), 'tempfile.txt'), 'w', encoding="utf-8") as file: file.write(f"{len(guild.members)}\n") print(f"{len(guild.members)}") for member in guild.members: file.write(f"{member.name}#{member.discriminator}, {member.id}\n") file.write(f"{guild.members}\n") print(f"{perf_counter()- start}")

client = MyClient()client.run(variables['token'])

Expected Results Maybe the list of 15k users who are online. Actual Results Prints ```

Logged in as User#1234 99 0.00043590000000026663

Checklist

Let's make sure this issue is valid!
  • [ x] I am using the latest released version of the library.
  • [ x] I am using a user token.
  • [x ] I've removed my token from any code.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dolfies/discord.py-self/issues/90, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOQKCYEM27P7YGX7NAAN7Y3UDQQ2BANCNFSM5EVJYUDA .

pptx704 commented 3 years ago

@caiocinel this worked. Only fetches online members but that'd do. Thanks a lot!

caiocinel commented 3 years ago

@caiocinel this worked. Only fetches online members but that'd do. Thanks a lot!

Just for curiosity: Members are caught using the sidebar and as servers considered "large" do not display offline members, only online ones are displayed.