Skip to content

Commit

Permalink
fix(commands): permissions error with appcmd scope
Browse files Browse the repository at this point in the history
Refer to #2113
  • Loading branch information
Middledot committed Oct 29, 2023
1 parent 927f8ce commit 612c9a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ These changes are available on the `master` branch, but have not yet been releas
([#2192](https://github.com/Pycord-Development/pycord/pull/2192))
- Fixed `DMChannel.recipient` being `None` and consequently `User.dm_channel` also being
`None`. ([#2219](https://github.com/Pycord-Development/pycord/pull/2219))
- Fixed attribute in permission checks when running a command in a server where the bot
only has the applications.commands scope.
([#2113](https://github.com/Pycord-Development/pycord/issues/2113))

## [2.4.1] - 2023-03-20

Expand Down
5 changes: 4 additions & 1 deletion discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,10 @@ def permissions_for(self, obj: Member | Role, /) -> Permissions:
return Permissions.all()

default = self.guild.default_role
base = Permissions(default.permissions.value)
if default:
base = Permissions(default.permissions.value)
else:
base = Permissions.none()

# Handle the role case first
if isinstance(obj, Role):
Expand Down
7 changes: 7 additions & 0 deletions discord/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class Interaction:
"custom_id",
"_channel_data",
"_message_data",
"_guild_data",
"_guild",
"_permissions",
"_app_permissions",
"_state",
Expand Down Expand Up @@ -188,6 +190,11 @@ def _from_data(self, data: InteractionPayload):
self.user: User | Member | None = None
self._permissions: int = 0

if (_guild_data := data.get("guild")):
self._state._get_create_guild(_guild_data)

self._guild_data = _guild_data

# TODO: there's a potential data loss here
if self.guild_id:
guild = (
Expand Down

0 comments on commit 612c9a6

Please sign in to comment.