2424
2525from typing import TYPE_CHECKING , Optional , Union
2626
27+ import discord .abc
28+
2729if TYPE_CHECKING :
2830 import discord
31+ from discord .state import ConnectionState
2932
3033from ..guild import Guild
3134from ..interactions import Interaction , InteractionResponse
3235from ..member import Member
3336from ..message import Message
3437from ..user import User
3538from ..utils import cached_property
36- from ..context_managers import Typing
3739
3840
39- class ApplicationContext :
41+ class ApplicationContext ( discord . abc . Messageable ) :
4042 """Represents a Discord interaction context.
4143
4244 This class is not created manually and is instead passed to application
@@ -58,6 +60,10 @@ def __init__(self, bot: "discord.Bot", interaction: Interaction):
5860 self .bot = bot
5961 self .interaction = interaction
6062 self .command = None
63+ self ._state : ConnectionState = self .interaction ._state
64+
65+ async def _get_channel (self ) -> discord .abc .Messageable :
66+ return self .channel
6167
6268 @cached_property
6369 def channel (self ):
@@ -87,9 +93,6 @@ def user(self) -> Optional[Union[Member, User]]:
8793 def voice_client (self ):
8894 return self .guild .voice_client
8995
90- def typing (self ):
91- return Typing (self .channel )
92-
9396 @cached_property
9497 def response (self ) -> InteractionResponse :
9598 return self .interaction .response
@@ -100,11 +103,6 @@ def response(self) -> InteractionResponse:
100103 def respond (self ):
101104 return self .followup .send if self .response .is_done () else self .interaction .response .send_message
102105
103- @property
104- def send (self ):
105- """Behaves like :attr:`~discord.abc.Messagable.send` if the response is done, else behaves like :attr:`~discord.app.ApplicationContext.respond`"""
106- return self .channel .send if self .response .is_done () else self .respond
107-
108106 @property
109107 def defer (self ):
110108 return self .interaction .response .defer
0 commit comments