[commands] Fix Context.defer unconditionally deferring

This commit is contained in:
Rapptz 2024-10-13 14:26:40 -04:00
parent 442ad40ab2
commit ca85782b35

View File

@ -87,11 +87,15 @@ class DeferTyping:
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,