diff --git a/CHANGELOG.md b/CHANGELOG.md index bd7b286bce..e8e301fbda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/discord/abc.py b/discord/abc.py index 71a307ab87..16ae7fcda8 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -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): diff --git a/discord/interactions.py b/discord/interactions.py index 83ca14f128..157c77bca3 100644 --- a/discord/interactions.py +++ b/discord/interactions.py @@ -149,6 +149,8 @@ class Interaction: "custom_id", "_channel_data", "_message_data", + "_guild_data", + "_guild", "_permissions", "_app_permissions", "_state", @@ -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 = (