24
24
25
25
from typing import TYPE_CHECKING , Optional , Union
26
26
27
+ import discord .abc
28
+
27
29
if TYPE_CHECKING :
28
30
import discord
31
+ from discord .state import ConnectionState
29
32
30
33
from ..guild import Guild
31
34
from ..interactions import Interaction , InteractionResponse
32
35
from ..member import Member
33
36
from ..message import Message
34
37
from ..user import User
35
38
from ..utils import cached_property
36
- from ..context_managers import Typing
37
39
38
40
39
- class ApplicationContext :
41
+ class ApplicationContext ( discord . abc . Messageable ) :
40
42
"""Represents a Discord interaction context.
41
43
42
44
This class is not created manually and is instead passed to application
@@ -58,6 +60,10 @@ def __init__(self, bot: "discord.Bot", interaction: Interaction):
58
60
self .bot = bot
59
61
self .interaction = interaction
60
62
self .command = None
63
+ self ._state : ConnectionState = self .interaction ._state
64
+
65
+ async def _get_channel (self ) -> discord .abc .Messageable :
66
+ return self .channel
61
67
62
68
@cached_property
63
69
def channel (self ):
@@ -87,9 +93,6 @@ def user(self) -> Optional[Union[Member, User]]:
87
93
def voice_client (self ):
88
94
return self .guild .voice_client
89
95
90
- def typing (self ):
91
- return Typing (self .channel )
92
-
93
96
@cached_property
94
97
def response (self ) -> InteractionResponse :
95
98
return self .interaction .response
@@ -100,11 +103,6 @@ def response(self) -> InteractionResponse:
100
103
def respond (self ):
101
104
return self .followup .send if self .response .is_done () else self .interaction .response .send_message
102
105
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
-
108
106
@property
109
107
def defer (self ):
110
108
return self .interaction .response .defer
0 commit comments