Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(commands): fix permission check edge case #2253

Merged
merged 5 commits into from
Nov 29, 2023

Conversation

Middledot
Copy link
Member

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

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

discord/interactions.py Outdated Show resolved Hide resolved
discord/abc.py Outdated Show resolved Hide resolved
Co-authored-by: Dorukyum <[email protected]>
Signed-off-by: Middledot <[email protected]>
@Dorukyum Dorukyum enabled auto-merge (squash) November 29, 2023 17:27
@Dorukyum Dorukyum merged commit 99725dd into master Nov 29, 2023
45 checks passed
@Dorukyum Dorukyum deleted the 2113-permissions-with-appcmdscope branch November 29, 2023 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attribute error when checking for permissions with has_permissions
2 participants