@@ -396,18 +396,14 @@ def is_done(self) -> bool:
396
396
397
397
async def defer (self , * , ephemeral : bool = False ) -> None :
398
398
"""|coro|
399
-
400
399
Defers the interaction response.
401
-
402
400
This is typically used when the interaction is acknowledged
403
401
and a secondary action will be done later.
404
-
405
402
Parameters
406
403
-----------
407
404
ephemeral: :class:`bool`
408
405
Indicates whether the deferred message will eventually be ephemeral.
409
- This only applies for interactions of type :attr:`InteractionType.application_command`.
410
-
406
+ If ``True`` for interactions of type :attr:`InteractionType.component`, this will send an ephemeral 'bot is thinking' message in the channel.
411
407
Raises
412
408
-------
413
409
HTTPException
@@ -416,20 +412,24 @@ async def defer(self, *, ephemeral: bool = False) -> None:
416
412
This interaction has already been responded to before.
417
413
"""
418
414
if self ._responded :
419
- raise InteractionResponded (self ._parent )
415
+ raise discord . InteractionResponded (self ._parent )
420
416
421
417
defer_type : int = 0
422
- data : Optional [ Dict [ str , Any ]] = None
418
+ data = None
423
419
parent = self ._parent
424
- if parent .type is InteractionType .component :
425
- defer_type = InteractionResponseType .deferred_message_update .value
426
- elif parent .type is InteractionType .application_command :
427
- defer_type = InteractionResponseType .deferred_channel_message .value
420
+ if parent .type is discord .InteractionType .component :
421
+ if ephemeral :
422
+ data = {'flags' : 64 }
423
+ defer_type = discord .InteractionResponseType .deferred_channel_message .value
424
+ else :
425
+ defer_type = discord .InteractionResponseType .deferred_message_update .value
426
+ elif parent .type is discord .InteractionType .application_command :
427
+ defer_type = discord .InteractionResponseType .deferred_channel_message .value
428
428
if ephemeral :
429
429
data = {'flags' : 64 }
430
430
431
431
if defer_type :
432
- adapter = async_context .get ()
432
+ adapter = discord . webhook . async_ . async_context .get ()
433
433
await adapter .create_interaction_response (
434
434
parent .id , parent .token , session = parent ._session , type = defer_type , data = data
435
435
)
@@ -840,4 +840,4 @@ async def inner_call(delay: float = delay):
840
840
841
841
asyncio .create_task (inner_call ())
842
842
else :
843
- await self ._state ._interaction .delete_original_message ()
843
+ await self ._state ._interaction .delete_original_message ()
0 commit comments