Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

discord.js says the reply to this interaction has not been sent or deferred

ErrorThe reply to this interaction has not been sent or deferred.

Short answer

discord.js raises this when code edits or follows up an interaction that has no initial response yet. Send reply() or deferReply() first, within three seconds of the command arriving, and only then call editReply() or followUp(). Slow work should defer first, then edit the reply when it finishes.

  • Applies to discord.js 14, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open your command handler and list every call on the interaction in the order it runs. The first call must be reply() or deferReply(); an editReply() or followUp() that comes earlier is the bug.

    grep -rn "editReply\|followUp\|deferReply\|interaction.reply" src/commands
  2. 2Match what you see, then jump to its fix

    1. 1The error names the missing reply on a line that calls editReply() or followUp()editReply or followUp runs before any initial responseFix
    2. 2The command takes a few seconds (database, HTTP call) and Discord shows it failedSlow work runs before the first response and the 3-second window closesFix
    3. 3Only some inputs fail, for example when a lookup returns nothingA branch ends without ever respondingFix

What does the error look like?

  • The reply to this interaction has not been sent or deferred.
  • Slash command shows a loading state forever, or fails in the Discord client

Cause 1 of 3

editReply or followUp runs before any initial response

1Check

The guide describes reply() and deferReply() as the initial responses, and editReply() and followUp() as things you do after an initial response. Look for a code path where the second kind is reached first, for example inside an early branch.

grep -n -B6 "editReply" src/commands/*.js

2Fix

Make the first call on every path a reply() or a deferReply(), and keep editReply() for after it.

await interaction.deferReply();
const result = await buildReport();
await interaction.editReply(`Done: ${result}`);

3Verify

Run the command in a test server. It answers once and nothing is thrown.

node src/index.js

Confirmed by discordjs.guide

Did this fix it?

Cause 2 of 3

Slow work runs before the first response and the 3-second window closes

1Check

Discord requires an initial response within 3 seconds of receiving the event, or the token is invalidated. Any await before your first reply counts against that time.

grep -n "await" src/commands/report.js | head

2Fix

Call deferReply() as the very first line, then do the slow work, then editReply(). You then have up to 15 minutes before the token becomes invalid.

async execute(interaction) {
  await interaction.deferReply();
  const rows = await db.query('SELECT 1');
  await interaction.editReply(`Rows: ${rows.length}`);
}

3Verify

Time the command. The loading state appears at once and the edit lands when the work ends.

console.time('cmd'); // wrap the handler and print console.timeEnd('cmd') at the end

Confirmed by docs.discord.com

Did this fix it?

Cause 3 of 3

A branch ends without ever responding

1Check

Each interaction needs one initial response. An if-branch that returns early, or a catch block that only logs, leaves the interaction unanswered.

grep -n "return;\|catch" src/commands/*.js

2Fix

Reply in every branch, including the not-found and error paths. reply() and deferReply() cannot send additional messages, so use followUp() for anything after the first.

const item = await lookup(interaction.options.getString('name'));
if (!item) {
  await interaction.reply('Nothing found.'); // answer on this path too
  return;
}
await interaction.reply(`Found: ${item.name}`);

3Verify

Trigger the failing input on purpose and check that Discord shows your message.

node src/index.js

Confirmed by discordjs.guide

Did this fix it?

How do I stop it coming back?

  • Put deferReply() at the top of any command that touches a database or another API.
  • Review every early return in a handler and check that it answers the interaction first.
  • Remember the 15-minute limit on editReply() and followUp() after the first response.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Back end

ng serve cannot find the dev-server builder package

Could not find the implementation for builder @angular/build:dev-server

The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.