@@ -119,8 +119,10 @@ 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
+
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.
124
126
channel_id: Optional[:class:`int`]
125
127
The ID of the channel the interaction was sent from.
126
128
application_id: :class:`int`
@@ -270,11 +272,22 @@ def _from_data(self, data: InteractionPayload):
270
272
me = self .user , data = channel , state = self ._state
271
273
)
272
274
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 )
276
278
else :
277
- self .channel = self .cached_channel
279
+ if self .guild :
280
+ self .channel = self .guild and 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
+ )
278
291
279
292
self ._channel_data = channel
280
293
@@ -305,29 +318,6 @@ def is_component(self) -> bool:
305
318
"""Indicates whether the interaction is a message component."""
306
319
return self .type == InteractionType .component
307
320
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
-
331
321
@property
332
322
def permissions (self ) -> Permissions :
333
323
"""The resolved permissions of the member in the channel, including overwrites.
0 commit comments