[Python] Slash command not responding and error when I use defer() or response.send_message...

Discussão em 'Python' iniciado por Stack, Maio 6, 2025.

  1. Stack

    Stack Membro Participativo

    I’m working on a Discord bot using Python & discord.py and facing an issue with defer() and send_message() in my slash commands. Every time I use a command, it returns "The application did not respond," but sometimes it works just fine afterward.

    At first i tried:

    @bot.tree.command(name="check_ban", description="Check ban status of accounts")
    async def check_ban(inter: discord.Interaction):
    log(f"[check_ban] Command invoked by user={inter.user.id}")
    if await check_restriction(inter):
    log(f"[check_ban] Aborted: user={inter.user.id} is restricted")
    return

    log(f"[check_ban] Sending inter response")
    await inter.response.send_message("Checking ban status...", ephemeral=True)
    log(f"[check_ban] inter response sent")
    ...



    And i get:

    [ERROR] discord.app_commands.tree: Ignoring exception in command 'check_ban'
    Traceback (most recent call last):
    File "/home/discordbot/bot/venv/lib/python3.12/site-packages/discord/app_commands/commands.py", line 858, in _do_call
    return await self._callback(interaction, **params)
    File "/home/discordbot/bot/remainm.py", line 511, in check_ban
    await inter.response.send_message("Checking ban status...", ephemeral=True)
    File "/home/discordbot/bot/venv/lib/python3.12/site-packages/discord/interactions.py", line 1004, in send_message
    response = await adapter.create_interaction_response(
    File "/home/discordbot/bot/venv/lib/python3.12/site-packages/discord/webhook/async_.py", line 224, in request
    raise NotFound(response, data)
    discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction


    logged:

    [1746556901.163286][check_ban] Command invoked by user=7...
    [1746556901.1636057][check_ban] Sending inter response
    # nothing else here...


    Then i tried to replace it with a defer() :

    @bot.tree.command(name="check_ban", description="Check ban status of accounts")
    async def check_ban(inter: discord.Interaction):
    log(f"[check_ban] Command invoked by user={inter.user.id}")

    log(f"[check_ban] defering")
    await inter.response.defer(ephemeral=True)
    log(f"[check_ban] deferred")
    ...



    Got the same error 404 and logged the same thing:

    [1746557536.6729193][check_ban] Command invoked by user=7...
    [1746557536.673151][check_ban] defering
    # application did not repond


    try-except returns e=NotFound('404 Not Found (error code: 10062): Unknown interaction')

    I don't know if this matters but i did use followup.send() And again, sometimes the command works as it should. I have no clue why i get that error. Let me know if i didnt mention something important here and will be very grateful if someone help me

    Continue reading...

Compartilhe esta Página