Skip to content

Commit ff7fe71

Browse files
authored
Update interactions.py
1 parent 2bbf063 commit ff7fe71

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

discord/interactions.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -396,18 +396,14 @@ def is_done(self) -> bool:
396396

397397
async def defer(self, *, ephemeral: bool = False) -> None:
398398
"""|coro|
399-
400399
Defers the interaction response.
401-
402400
This is typically used when the interaction is acknowledged
403401
and a secondary action will be done later.
404-
405402
Parameters
406403
-----------
407404
ephemeral: :class:`bool`
408405
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.
411407
Raises
412408
-------
413409
HTTPException
@@ -416,20 +412,24 @@ async def defer(self, *, ephemeral: bool = False) -> None:
416412
This interaction has already been responded to before.
417413
"""
418414
if self._responded:
419-
raise InteractionResponded(self._parent)
415+
raise discord.InteractionResponded(self._parent)
420416

421417
defer_type: int = 0
422-
data: Optional[Dict[str, Any]] = None
418+
data = None
423419
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
428428
if ephemeral:
429429
data = {'flags': 64}
430430

431431
if defer_type:
432-
adapter = async_context.get()
432+
adapter = discord.webhook.async_.async_context.get()
433433
await adapter.create_interaction_response(
434434
parent.id, parent.token, session=parent._session, type=defer_type, data=data
435435
)
@@ -840,4 +840,4 @@ async def inner_call(delay: float = delay):
840840

841841
asyncio.create_task(inner_call())
842842
else:
843-
await self._state._interaction.delete_original_message()
843+
await self._state._interaction.delete_original_message()

0 commit comments

Comments
 (0)