27
27
from typing import TYPE_CHECKING , Dict , List , Optional , TypeVar , Union
28
28
29
29
import discord .abc
30
- from discord .interactions import InteractionMessage
30
+ from discord .interactions import InteractionMessage , InteractionResponse , Interaction
31
+ from discord .webhook .async_ import Webhook
31
32
32
33
if TYPE_CHECKING :
33
34
from typing_extensions import ParamSpec
@@ -137,26 +138,33 @@ async def invoke(
137
138
138
139
@cached_property
139
140
def channel (self ) -> Optional [InteractionChannel ]:
141
+ """Union[:class:`abc.GuildChannel`, :class:`PartialMessageable`, :class:`Thread`]:
142
+ Returns the channel associated with this context's command. Shorthand for :attr:`.Interaction.channel`."""
140
143
return self .interaction .channel
141
144
142
145
@cached_property
143
146
def channel_id (self ) -> Optional [int ]:
147
+ """:class:`int`: Returns the ID of the channel associated with this context's command. Shorthand for :attr:`.Interaction.channel.id`."""
144
148
return self .interaction .channel_id
145
149
146
150
@cached_property
147
151
def guild (self ) -> Optional [Guild ]:
152
+ """Optional[:class:`.Guild`]: Returns the guild associated with this context's command. Shorthand for :attr:`.Interaction.guild`."""
148
153
return self .interaction .guild
149
154
150
155
@cached_property
151
156
def guild_id (self ) -> Optional [int ]:
157
+ """:class:`int`: Returns the ID of the guild associated with this context's command. Shorthand for :attr:`.Interaction.guild.id`."""
152
158
return self .interaction .guild_id
153
159
154
160
@cached_property
155
161
def locale (self ) -> Optional [str ]:
162
+ """:class:`str`: Returns the locale of the guild associated with this context's command. Shorthand for :attr:`.Interaction.locale`."""
156
163
return self .interaction .locale
157
164
158
165
@cached_property
159
166
def guild_locale (self ) -> Optional [str ]:
167
+ """:class:`str`: Returns the locale of the guild associated with this context's command. Shorthand for :attr:`.Interaction.guild_locale`."""
160
168
return self .interaction .guild_locale
161
169
162
170
@cached_property
@@ -165,27 +173,35 @@ def app_permissions(self) -> Permissions:
165
173
166
174
@cached_property
167
175
def me (self ) -> Optional [Union [Member , ClientUser ]]:
176
+ """Union[:class:`.Member`, :class:`.ClientUser`]:
177
+ Similar to :attr:`.Guild.me` except it may return the :class:`.ClientUser` in private message
178
+ message contexts, or when :meth:`Intents.guilds` is absent.
179
+ """
168
180
return self .interaction .guild .me if self .interaction .guild is not None else self .bot .user
169
181
170
182
@cached_property
171
183
def message (self ) -> Optional [Message ]:
184
+ """Optional[:class:`.Message`]: Returns the message sent with this context's command. Shorthand for :attr:`.Interaction.message`, if applicable."""
172
185
return self .interaction .message
173
186
174
187
@cached_property
175
188
def user (self ) -> Optional [Union [Member , User ]]:
189
+ """Union[:class:`.Member`, :class:`.User`]: Returns the user that sent this context's command. Shorthand for :attr:`.Interaction.user`."""
176
190
return self .interaction .user
177
191
178
192
author : Optional [Union [Member , User ]] = user
179
193
180
194
@property
181
195
def voice_client (self ) -> Optional [VoiceProtocol ]:
196
+ """Optional[:class:`.VoiceProtocol`]: Returns the voice client associated with this context's command. Shorthand for :attr:`.Interaction.guild.voice_client`, if applicable."""
182
197
if self .interaction .guild is None :
183
198
return None
184
199
185
200
return self .interaction .guild .voice_client
186
201
187
202
@cached_property
188
203
def response (self ) -> InteractionResponse :
204
+ """:class:`.InteractionResponse`: Returns the response object associated with this context's command. Shorthand for :attr:`.Interaction.response`."""
189
205
return self .interaction .response
190
206
191
207
@property
@@ -222,8 +238,8 @@ def unselected_options(self) -> Optional[List[Option]]:
222
238
return None
223
239
224
240
@property
241
+ @discord .utils .copy_doc (InteractionResponse .send_modal )
225
242
def send_modal (self ) -> Callable [..., Awaitable [Interaction ]]:
226
- """Sends a modal dialog to the user who invoked the interaction."""
227
243
return self .interaction .response .send_modal
228
244
229
245
async def respond (self , * args , ** kwargs ) -> Union [Interaction , WebhookMessage ]:
@@ -246,6 +262,7 @@ async def respond(self, *args, **kwargs) -> Union[Interaction, WebhookMessage]:
246
262
return await self .followup .send (* args , ** kwargs )
247
263
248
264
@property
265
+ @discord .utils .copy_doc (InteractionResponse .send_message )
249
266
def send_response (self ) -> Callable [..., Awaitable [Interaction ]]:
250
267
if not self .interaction .response .is_done ():
251
268
return self .interaction .response .send_message
@@ -255,6 +272,7 @@ def send_response(self) -> Callable[..., Awaitable[Interaction]]:
255
272
)
256
273
257
274
@property
275
+ @discord .utils .copy_doc (Webhook .send )
258
276
def send_followup (self ) -> Callable [..., Awaitable [WebhookMessage ]]:
259
277
if self .interaction .response .is_done ():
260
278
return self .followup .send
@@ -264,11 +282,13 @@ def send_followup(self) -> Callable[..., Awaitable[WebhookMessage]]:
264
282
)
265
283
266
284
@property
285
+ @discord .utils .copy_doc (InteractionResponse .defer )
267
286
def defer (self ) -> Callable [..., Awaitable [None ]]:
268
287
return self .interaction .response .defer
269
288
270
289
@property
271
290
def followup (self ) -> Webhook :
291
+ """:class:`Webhook`: Returns the follow up webhook for follow up interactions."""
272
292
return self .interaction .followup
273
293
274
294
async def delete (self , * , delay : Optional [float ] = None ) -> None :
@@ -296,6 +316,7 @@ async def delete(self, *, delay: Optional[float] = None) -> None:
296
316
return await self .interaction .delete_original_message (delay = delay )
297
317
298
318
@property
319
+ @discord .utils .copy_doc (Interaction .edit_original_message )
299
320
def edit (self ) -> Callable [..., Awaitable [InteractionMessage ]]:
300
321
return self .interaction .edit_original_message
301
322
0 commit comments