Skip to content

Commit

Permalink
[commands] Fix Context.defer unconditionally deferring
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapptz committed Oct 13, 2024
1 parent 442ad40 commit ca85782
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions discord/ext/commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,15 @@ def __init__(self, ctx: Context[BotT], *, ephemeral: bool):
self.ctx: Context[BotT] = ctx
self.ephemeral: bool = ephemeral

async def do_defer(self) -> None:
if self.ctx.interaction and not self.ctx.interaction.response.is_done():
await self.ctx.interaction.response.defer(ephemeral=self.ephemeral)

def __await__(self) -> Generator[Any, None, None]:
return self.ctx.defer(ephemeral=self.ephemeral).__await__()
return self.do_defer().__await__()

async def __aenter__(self) -> None:
await self.ctx.defer(ephemeral=self.ephemeral)
await self.do_defer()

async def __aexit__(
self,
Expand Down

0 comments on commit ca85782

Please sign in to comment.