dolfies / discord.py-self

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

Gateway Ratelimit Error #494

Closed sumonhope closed 11 months ago

sumonhope commented 1 year ago

Summary

Rate limit on gateway for users in lots of discords

Reproduction Steps

client = MyClient()
client.run(user_token)

I noticed that on users with less channels, this line of code works. It breaks when using a user_token corresponding to an account in lots of discords.

Code

No response

Expected Results

INFO discord.client Logging in using static token. INFO discord.http Found user agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) ... INFO discord.gateway Connected to Gateway (Session ID: xxx).

Actual Results

INFO discord.client Logging in using static token. INFO discord.http Found user agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) ... INFO discord.gateway Connected to Gateway (Session ID: xxx). WARNING discord.gateway Gateway is ratelimited, waiting 57.55 seconds. WARNING discord.state Member list scraping failed for xxx (Failed to automatically choose channels; please specify them manually). WARNING discord.state Member list scraping failed for xxx (Failed to automatically choose channels; please specify them manually). WARNING discord.state Member list scraping failed for xxx (Failed to automatically choose channels; please specify them manually). WARNING discord.gateway Gateway is ratelimited, waiting 57.55 seconds. ...

^ Two warnings persist

System Information

Checklist

Additional Information

No response

enterv0id commented 12 months ago

Exact same issue here

dolfies commented 11 months ago

Those errors just mean the gateway was rate limited while trying to scrape guild members and parse events for guilds automatically. They can safely be ignored, it just means you won't have a full guild member cache for those guilds. If you don't want the library to do this at startup, you can pass the chunk_guilds_at_startup=False param to your Client constructor.

Note that the gateway may still get rate limited at startup if you are in over ~100 guilds, as the library sends a gateway command to subscribe to each guild you are in at startup. You can also disable this behavior with the request_guilds=False param, but I don't recommend doing so unless you want to manage guild subscriptions manually; it means you will not have a complete thread cache and will miss out on non-cache related events (e.g. on_message) for large guilds.