#how to make bot thinking
1 messages · Page 1 of 1 (latest)
await ctx.defer()
If your command takes more than 3 seconds to give a response, you might be getting an error back from Discord looking something like this:
This interaction failed. / Unknown interaction.
Discord expects you to respond to an interaction within 3 seconds in some manner. This may be restrictive, but Discord does allow for deferring - a type of response that specifies Discord to show a loading/thinking state for up to 15 minutes while you prepare your actual response.
To do this, add this to the beginning of your command's code:
# First way
@interactions.slash_command(...)
async def slash_command(ctx):
await ctx.defer()
...
# Second way
@interactions.slash_command(...)
@interactions.auto_defer(...)
async def slash_command_2(ctx):
...
If you wish for all of your commands to defer, then you can specify the auto_defer kwarg in your Client:
bot = Client(auto_defer=True, ...)
# If you want more control...
bot = Client(auto_defer=AutoDefer(...))