2929import datetime
3030from typing import TYPE_CHECKING , Any , Coroutine , Union , overload
3131
32+ from typing_extensions import deprecated
33+
3234from . import utils
3335from .channel import ChannelType , PartialMessageable , _threaded_channel_factory
3436from .enums import (
@@ -223,6 +225,7 @@ def __init__(self, *, data: InteractionPayload, state: ConnectionState):
223225 self ._session : ClientSession = state .http ._HTTPClient__session
224226 self ._original_response : InteractionMessage | None = None
225227 self .callback : InteractionCallback | None = None
228+ self ._cs_channel : InteractionChannel | None = MISSING
226229 self ._from_data (data )
227230
228231 def _from_data (self , data : InteractionPayload ):
@@ -357,14 +360,19 @@ def is_component(self) -> bool:
357360 """Indicates whether the interaction is a message component."""
358361 return self .type == InteractionType .component
359362
360- @utils .cached_slot_property ("_cs_channel" )
361- @utils .deprecated ("Interaction.channel" , "2.7" , stacklevel = 4 )
363+ @property
364+ @deprecated (
365+ "Interaction.cached_channel is deprecated since version 2.7, consider using Interaction.channel instead."
366+ )
362367 def cached_channel (self ) -> InteractionChannel | None :
363368 """The cached channel from which the interaction was sent.
364369 DM channels are not resolved. These are :class:`PartialMessageable` instead.
365370
366371 .. deprecated:: 2.7
367372 """
373+ if self ._cs_channel is not MISSING :
374+ return self ._cs_channel
375+ r : InteractionChannel | None = None
368376 guild = self .guild
369377 channel = guild and guild ._resolve_channel (self .channel_id )
370378 if channel is None :
@@ -374,11 +382,11 @@ def cached_channel(self) -> InteractionChannel | None:
374382 if self .guild_id is not None
375383 else ChannelType .private
376384 )
377- return PartialMessageable (
378- state = self . _state , id = self . channel_id , type = type
379- )
380- return None
381- return channel
385+ r = PartialMessageable (state = self . _state , id = self . channel_id , type = type )
386+ else :
387+ r = channel
388+ self . _cs_channel = r
389+ return r
382390
383391 @property
384392 def permissions (self ) -> Permissions :
@@ -496,7 +504,9 @@ async def original_response(self) -> InteractionMessage:
496504 self ._original_response = message
497505 return message
498506
499- @utils .deprecated ("Interaction.original_response" , "2.2" )
507+ @deprecated (
508+ "Interaction.original_message is deprecated since version 2.2, consider using Interaction.original_response instead."
509+ )
500510 async def original_message (self ):
501511 """An alias for :meth:`original_response`.
502512
@@ -642,7 +652,9 @@ async def edit_original_response(
642652
643653 return message
644654
645- @utils .deprecated ("Interaction.edit_original_response" , "2.2" )
655+ @deprecated (
656+ "Interaction.edit_original_message is deprecated since version 2.2, consider using Interaction.edit_original_response instead."
657+ )
646658 async def edit_original_message (self , ** kwargs ):
647659 """An alias for :meth:`edit_original_response`.
648660
@@ -700,7 +712,9 @@ async def delete_original_response(self, *, delay: float | None = None) -> None:
700712 else :
701713 await func
702714
703- @utils .deprecated ("Interaction.delete_original_response" , "2.2" )
715+ @deprecated (
716+ "Interaction.delete_original_message is deprecated since version 2.2, consider using Interaction.delete_original_response instead."
717+ )
704718 async def delete_original_message (self , ** kwargs ):
705719 """An alias for :meth:`delete_original_response`.
706720
@@ -1487,7 +1501,9 @@ async def send_modal(self, modal: BaseModal) -> Interaction:
14871501 self ._parent ._state .store_modal (modal , self ._parent .user .id )
14881502 return self ._parent
14891503
1490- @utils .deprecated ("a button with type ButtonType.premium" , "2.6" )
1504+ @deprecated (
1505+ "InteractionResponse.premium_required is deprecated since version 2.6, consider using a button with type ButtonType.premium instead."
1506+ )
14911507 async def premium_required (self ) -> Interaction :
14921508 """|coro|
14931509
0 commit comments