fix(GuildChannel): overload permissionsFor and BaseManager#resolve[id] #5260
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.
Please describe the changes this PR makes and why it should be merged:
The behaviour of GuildChannel#permissionsFor, is that if it's able to resolve the data, it will always return permissions (since the private methods
memberPermissions
androlePermissions
never returnnull
):discord.js/src/structures/GuildChannel.js
Lines 113 to 119 in 9ffcd83
For data to be resolvable, it expects either an instance or a string:
discord.js/src/managers/BaseManager.js
Lines 59 to 63 in 9ffcd83
If an instance is provided, it will always return the instance itself, therefore, when passing a value that matches
Holds
, the type return should always beHolds
as well.When passing a string, the return can be nullable, so this is excluded from the non-nullable return.
Things change when
GuildMemberManager#resolve
is used, as it's overloaded to support more types (specificallyUser
instances), which resolves an ID and then tries to get theGuildMember
from it, that is why I am not usingExclude<GuildMemberResolvable | RoleResolvable, string>
.discord.js/src/managers/GuildMemberManager.js
Lines 46 to 52 in 9ffcd83
Status
Semantic versioning classification: