@@ -119,7 +119,7 @@ class Interaction:
119119 The interaction type.
120120 guild_id: Optional[:class:`int`]
121121 The guild ID the interaction was sent from.
122- channel: Optional[Union[:class:`abc.GuildChannel`, :class:`abc.PrivateChannel`, :class:`Thread`]]
122+ channel: Optional[Union[:class:`abc.GuildChannel`, :class:`abc.PrivateChannel`, :class:`Thread`, :class:`PartialMessageable` ]]
123123 The channel the interaction was sent from.
124124 channel_id: Optional[:class:`int`]
125125 The ID of the channel the interaction was sent from.
@@ -261,20 +261,23 @@ def _from_data(self, data: InteractionPayload):
261261 except KeyError :
262262 pass
263263
264- if channel := data .get ("channel" ):
265- if (ch_type := channel .get ("type" )) is not None :
266- factory , ch_type = _threaded_channel_factory (ch_type )
264+ channel = data .get ("channel" )
265+ data_ch_type : int | None = channel .get ("type" ) if channel else None
267266
268- if ch_type in (ChannelType .group , ChannelType .private ):
269- self .channel = factory (
270- me = self .user , data = channel , state = self ._state
271- )
272- elif self .guild :
273- self .channel = factory (
274- guild = self .guild , state = self ._state , data = channel
275- )
276- else :
277- self .channel = self .cached_channel
267+ if data_ch_type is not None :
268+ factory , ch_type = _threaded_channel_factory (data_ch_type )
269+ if ch_type in (ChannelType .group , ChannelType .private ):
270+ self .channel = factory (me = self .user , data = channel , state = self ._state )
271+
272+ if self .channel is None and self .guild :
273+ self .channel = self .guild ._resolve_channel (self .channel_id )
274+ if self .channel is None and self .channel_id is not None :
275+ ch_type = (
276+ ChannelType .text if self .guild_id is not None else ChannelType .private
277+ )
278+ self .channel = PartialMessageable (
279+ state = self ._state , id = self .channel_id , type = ch_type
280+ )
278281
279282 self ._channel_data = channel
280283
@@ -306,12 +309,12 @@ def is_component(self) -> bool:
306309 return self .type == InteractionType .component
307310
308311 @utils .cached_slot_property ("_cs_channel" )
312+ @utils .deprecated ("Interaction.channel" , "2.7" , stacklevel = 4 )
309313 def cached_channel (self ) -> InteractionChannel | None :
310- """The channel the
311- interaction was sent from .
314+ """The cached channel from which the interaction was sent.
315+ DM channels are not resolved. These are :class:`PartialMessageable` instead .
312316
313- Note that due to a Discord limitation, DM channels are not resolved since there is
314- no data to complete them. These are :class:`PartialMessageable` instead.
317+ .. deprecated:: 2.7
315318 """
316319 guild = self .guild
317320 channel = guild and guild ._resolve_channel (self .channel_id )
0 commit comments