Skip to content

Commit 1881547

Browse files
committed
🗑️ Deprecate instead of remove cached_channel
1 parent 96a3141 commit 1881547

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

discord/interactions.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,29 @@ def is_component(self) -> bool:
319319
"""Indicates whether the interaction is a message component."""
320320
return self.type == InteractionType.component
321321

322+
@utils.cached_slot_property("_cs_channel")
323+
@utils.deprecated("Interaction.channel", "2.7")
324+
def cached_channel(self) -> InteractionChannel | None:
325+
"""The cached channel the interaction was sent from.
326+
DM channels are not resolved. These are :class:`PartialMessageable` instead.
327+
328+
.. deprecated:: 2.7
329+
"""
330+
guild = self.guild
331+
channel = guild and guild._resolve_channel(self.channel_id)
332+
if channel is None:
333+
if self.channel_id is not None:
334+
type = (
335+
ChannelType.text
336+
if self.guild_id is not None
337+
else ChannelType.private
338+
)
339+
return PartialMessageable(
340+
state=self._state, id=self.channel_id, type=type
341+
)
342+
return None
343+
return channel
344+
322345
@property
323346
def permissions(self) -> Permissions:
324347
"""The resolved permissions of the member in the channel, including overwrites.

0 commit comments

Comments
 (0)