@@ -119,8 +119,10 @@ 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.
124+
125+ Note that due to a Discord limitation, DM channels are not resolved since there is no data to complete them. These are :class:`PartialMessageable` instead.
124126 channel_id: Optional[:class:`int`]
125127 The ID of the channel the interaction was sent from.
126128 application_id: :class:`int`
@@ -270,11 +272,22 @@ def _from_data(self, data: InteractionPayload):
270272 me = self .user , data = channel , state = self ._state
271273 )
272274 elif self .guild :
273- self .channel = factory (
274- guild = self .guild , state = self . _state , data = channel
275- )
275+ self .channel = self . guild . _resolve_channel (
276+ self .channel_id
277+ ) or factory ( guild = self . guild , state = self . _state , data = channel )
276278 else :
277- self .channel = self .cached_channel
279+ if self .guild :
280+ self .channel = self .guild ._resolve_channel (self .channel_id )
281+ if self .channel is None :
282+ if self .channel_id is not None :
283+ ch_type = (
284+ ChannelType .text
285+ if self .guild_id is not None
286+ else ChannelType .private
287+ )
288+ return PartialMessageable (
289+ state = self ._state , id = self .channel_id , type = ch_type
290+ )
278291
279292 self ._channel_data = channel
280293
@@ -305,29 +318,6 @@ def is_component(self) -> bool:
305318 """Indicates whether the interaction is a message component."""
306319 return self .type == InteractionType .component
307320
308- @utils .cached_slot_property ("_cs_channel" )
309- def cached_channel (self ) -> InteractionChannel | None :
310- """The channel the
311- interaction was sent from.
312-
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.
315- """
316- guild = self .guild
317- channel = guild and guild ._resolve_channel (self .channel_id )
318- if channel is None :
319- if self .channel_id is not None :
320- type = (
321- ChannelType .text
322- if self .guild_id is not None
323- else ChannelType .private
324- )
325- return PartialMessageable (
326- state = self ._state , id = self .channel_id , type = type
327- )
328- return None
329- return channel
330-
331321 @property
332322 def permissions (self ) -> Permissions :
333323 """The resolved permissions of the member in the channel, including overwrites.
0 commit comments