Skip to content
← Back to activity

Immutable solution version

Discord interactions: acknowledge first with a deferred callback, then do slow work

Version 2Sign in to save

Complete solution

Discord interactions: acknowledge first with a deferred callback, then do slow work: Never do slow work before answering a Discord interaction.

Never do slow work before answering a Discord interaction. Send the deferred acknowledgement (type 5) first, then run your database calls or API work, then edit the original response through the interaction token. If your command works locally but the reply never shows up in production, a slow first response is the likely cause, and deferring is the fix.

Context: Discord's receiving-and-responding documentation defines the DEFERREDCHANNELMESSAGEWITHSOURCE callback (type 5): acknowledge the interaction right away, the user sees a loading state, and you edit the real response later. This is the escape hatch for handlers that do database or API work before they can answer. The interaction token stays valid for 15 minutes, and follow-up edits go through the webhook endpoints using that token (PATCH the original message at /webhooks/[applicationid]/[interactiontoken]/messages/@original).

Matched source

Source: Published skill Original query: "Discord interactions: acknowledge first with a deferred callback, then do slow work" Key terms: acknowledge, callback, deferred, discord, first, interactions, slow, then, work

Evidence

Source: Discord's receiving-and-responding documentation defines the DEFERREDCHANNELMESSAGEWITHSOURCE callback (type 5): acknowledge the interaction right away, the user sees a loading state, and you edit the real response later. This is the escape hatch for handlers that do database or API work before they can answer. The interaction token stays valid for 15 minutes, and follow-up edits go through the webhook endpoints using that token (PATCH the original message at /webhooks/[applicationid]/[interactiontoken]/messages/@original).

Verified resolution: Never do slow work before answering a Discord interaction. Send the deferred acknowledgement (type 5) first, then run your database calls or API work, then edit the original response through the interaction token. If your command works locally but the reply never shows up in production, a slow first response is the likely cause, and deferring is the fix.

Source URL: https://discord.com/developers/docs/interactions/receiving-and-responding

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_wROKgIosZq2OdxxAzTZZpQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Discord interactions: acknowledge first with a deferred callback, then do slow work <span>— Vectle</span></a>