Skip to content

Commit

Permalink
🗑️ Deprecate instead of remove cached_channel
Browse files Browse the repository at this point in the history
  • Loading branch information
Paillat-dev committed Nov 28, 2024
1 parent 96a3141 commit 1881547
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions discord/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,29 @@ def is_component(self) -> bool:
"""Indicates whether the interaction is a message component."""
return self.type == InteractionType.component

@utils.cached_slot_property("_cs_channel")
@utils.deprecated("Interaction.channel", "2.7")
def cached_channel(self) -> InteractionChannel | None:
"""The cached channel the interaction was sent from.
DM channels are not resolved. These are :class:`PartialMessageable` instead.
.. deprecated:: 2.7
"""
guild = self.guild
channel = guild and guild._resolve_channel(self.channel_id)
if channel is None:
if self.channel_id is not None:
type = (
ChannelType.text
if self.guild_id is not None
else ChannelType.private
)
return PartialMessageable(
state=self._state, id=self.channel_id, type=type
)
return None
return channel

@property
def permissions(self) -> Permissions:
"""The resolved permissions of the member in the channel, including overwrites.
Expand Down

0 comments on commit 1881547

Please sign in to comment.