fix(commands): fix permission check edge case #2253
Merged
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.
Summary
Fixes #2113
Inviting a bot to a server with only the applications.commands scope results in permission checks giving AttributeError because it can't crosscheck permissions of channel and user to the default role of the server (interaction gives a partial guild object).
I decided to fix this by assuming the default role has no permissions (so permission checks always fail)
I also made it so that a guild object is created and accessible from
interaction.guild
but not added to the cache. I was thinking it shouldn't be added to state because this is a weird edge case that pycord v2 doesn't support, and the guild only has "locale", "id", and "features" (which is an empty list).Information
examples, ...).
Checklist
type: ignore
comments were used, a comment is also left explaining why.