Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Type
Description
This PR adds a
guild_count
property to bothClient
andClientUser
. It does exactly as you may expect - it gets the number of guilds the client is in. Compared tolen(bot.guilds)
, this method avoids using cache lookups, which takes up a significant amount of time as the number of guilds a bot is in grows.The debug extension has been modified to use this property too, although the websocket ready instance was left as-is (sans a comment) since that could result in differing behavior - there are cases where
len(bot.guilds)
is notbot.guild_count
, most notably if the guild is not in the cache. For normal users, though, this difference likely doesn't matter.Changes
bot.guild_count
.bot.user.guild_count
.guild_count
.Related Issues
N/A
Test Scenarios
Python Compatibility
A variant of this code has been working for over a year for the Realms Playerlist Bot.
3.10.x
3.11.x
Checklist
pre-commit
code linter over all edited files