Skip to content

Commit

Permalink
feat: use _app_permissions in (g)dm contexts as well
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftinv committed Nov 27, 2024
1 parent 07e6853 commit fbab8cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 4 additions & 9 deletions disnake/interactions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ def __init__(self, *, data: InteractionPayload, state: ConnectionState) -> None:
)
self._permissions = int(member.get("permissions", 0))
elif user := data.get("user"):
# TODO: this shouldn't store users, since they don't necessarily get evicted
self.author = self._state.store_user(user)

# TODO: consider making this optional in 3.0
Expand Down Expand Up @@ -335,16 +334,12 @@ def permissions(self) -> Permissions:
def app_permissions(self) -> Permissions:
""":class:`Permissions`: The resolved permissions of the bot in the channel, including overwrites.
In a guild context, this is provided directly by Discord.
In a non-guild context this will be an instance of :meth:`Permissions.private_channel`.
.. versionadded:: 2.6
.. versionchanged:: 2.10
This is now always provided by Discord.
"""
if self.guild_id:
return Permissions(self._app_permissions)
# TODO: this fallback should be unnecessary now
return Permissions.private_channel()
return Permissions(self._app_permissions)

@utils.cached_slot_property("_cs_response")
def response(self) -> InteractionResponse:
Expand Down
2 changes: 0 additions & 2 deletions disnake/types/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

ApplicationCommandType = Literal[1, 2, 3]

# TODO: naming?
# to quote the notion doc, "Not limited to application command interactions. Unfortunate naming here"
InteractionContextType = Literal[1, 2, 3] # GUILD, BOT_DM, PRIVATE_CHANNEL


Expand Down

0 comments on commit fbab8cc

Please sign in to comment.