pythondiscordpycord

pycord bot quits slash command too quick


When my bot is very busy, it sometimes takes a few seconds to respond to the slash commands. However, before he can reply, Discord sends the message "The application did not respond". How can I make Discord wait longer for a message from the bot?


Solution

  • Have you tried using Interaction.defer()? Here's a quick example on how to use that:

    @bot_instance.slash_command(name="hi")
    async def hi(ctx):
       await ctx.defer()
       # fairly long task?
       await ctx.followup.send( # Whatever you want to send...
    

    For more information check out the API Reference: https://docs.pycord.dev/en/stable/api/models.html#discord.Interaction

    Also see a GitHub issue related to this question: https://github.com/Pycord-Development/pycord/issues/264