Skip to content

deferReply() not working properly in Bun #11296

@Mahonzu

Description

@Mahonzu

Which package is this bug report for?

discord.js

Issue description

Steps to reproduce:

  1. Replace Bun.env.TOKEN with your bot's token
  2. bun run sample.ts
  3. use /ping on the bot
  4. See "<application> is thinking..." forever
    From my testing it either awaits deferReply forever, or throws both The reply to this interaction has not been sent or deferred. and Interaction has already been acknowledged.
    Works completely fine with node and deno

Code sample

import { Client, Events, MessageFlags } from "discord.js"; 
const client = new Client({ intents: [] });

const sleep = (ms:number) => {
    return new Promise(resolve => setTimeout(resolve, ms));
}

client.once(Events.ClientReady, (readyClient) => {
	console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});
client.on(Events.InteractionCreate, async (interaction) => {
	if (!interaction.isChatInputCommand()) return;
	
	if (interaction.commandName == "ping") {
		await interaction.deferReply({ flags: MessageFlags.Ephemeral });
		await sleep(1000)
		await interaction.editReply({ content: "pong" });
	}
});

client.login(Bun.env.TOKEN);

Versions

  • discord.js: 14.24.2
  • Bun: 1.3.2
  • OS: archlinux 6.17.8-arch1-1

Issue priority

Medium (should be fixed soon)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

No Intents

I have tested this issue on a development release

02fc101

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions