Browse Source

Add Interaction.app_permissions

Fix #8193
pull/8198/head
Rapptz 3 years ago
parent
commit
b3a24846bd
  1. 7
      discord/interactions.py
  2. 1
      discord/types/interactions.py

7
discord/interactions.py

@ -133,6 +133,7 @@ class Interaction:
'guild_locale', 'guild_locale',
'extras', 'extras',
'_permissions', '_permissions',
'_app_permissions',
'_state', '_state',
'_client', '_client',
'_session', '_session',
@ -182,6 +183,7 @@ class Interaction:
self.user: Union[User, Member] = MISSING self.user: Union[User, Member] = MISSING
self._permissions: int = 0 self._permissions: int = 0
self._app_permissions: int = int(data.get('app_permissions', 0))
if self.guild_id: if self.guild_id:
guild = self._state._get_or_create_unavailable_guild(self.guild_id) guild = self._state._get_or_create_unavailable_guild(self.guild_id)
@ -236,6 +238,11 @@ class Interaction:
""" """
return Permissions(self._permissions) return Permissions(self._permissions)
@property
def app_permissions(self) -> Permissions:
""":class:`Permissions`: The resolved permissions of the application or the bot, including overwrites."""
return Permissions(self._app_permissions)
@utils.cached_slot_property('_cs_namespace') @utils.cached_slot_property('_cs_namespace')
def namespace(self) -> Namespace: def namespace(self) -> Namespace:
""":class:`app_commands.Namespace`: The resolved namespace for this interaction. """:class:`app_commands.Namespace`: The resolved namespace for this interaction.

1
discord/types/interactions.py

@ -203,6 +203,7 @@ class _BaseInteraction(TypedDict):
version: Literal[1] version: Literal[1]
guild_id: NotRequired[Snowflake] guild_id: NotRequired[Snowflake]
channel_id: NotRequired[Snowflake] channel_id: NotRequired[Snowflake]
app_permissions: NotRequired[str]
locale: NotRequired[str] locale: NotRequired[str]
guild_locale: NotRequired[str] guild_locale: NotRequired[str]

Loading…
Cancel
Save