Allow passing in member for calculating effective permissions #873
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.
Description:
Allow passing in a proper
Member
object intoGuildChannel#getEffectivePermissions
instead of just aSnowflakeId
.Justification:
This allows optimizations of rest requests in certain situations.
When the GUILDS intent is used, but not the GUILD_MEMBERS intent, calling
getEffectivePermissions
with just the SnowflakeId of the user will result in a REST request to fetch the member (but no other request, as the owner, role data, etc can be served from the entity cache). In some situations it is unnecessary to fetch the member from the API. AMessageCreateEvent
contains aMember
object for the author, so if we wanted to check their permissions, we could avoid that API request by passing that member object togetEffectivePermissions
, reducing the amount of necessary API requests to 0.Another smaller use case would be checking self permissions. At a large scale, with the GUILD_MEMBERS intent not enabled, a bot author might want to have the option to handle caching their self member objects outside the entity cache, to heuristically reduce API calls for certain non-critical self permissions checks.