@@ -119,7 +119,7 @@ class Interaction:
119
119
The interaction type.
120
120
guild_id: Optional[:class:`int`]
121
121
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` ]]
123
123
The channel the interaction was sent from.
124
124
channel_id: Optional[:class:`int`]
125
125
The ID of the channel the interaction was sent from.
@@ -261,20 +261,23 @@ def _from_data(self, data: InteractionPayload):
261
261
except KeyError :
262
262
pass
263
263
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
267
266
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
+ )
278
281
279
282
self ._channel_data = channel
280
283
@@ -306,12 +309,12 @@ def is_component(self) -> bool:
306
309
return self .type == InteractionType .component
307
310
308
311
@utils .cached_slot_property ("_cs_channel" )
312
+ @utils .deprecated ("Interaction.channel" , "2.7" , stacklevel = 4 )
309
313
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 .
312
316
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
315
318
"""
316
319
guild = self .guild
317
320
channel = guild and guild ._resolve_channel (self .channel_id )
0 commit comments