Inconsistent Timing in `ModalInteraction.deferReply()`

The function ModalInteraction.deferReply() is exhibiting inconsistent behavior. Instead of taking a constant interval of time to execute, it is taking a random amount of time.
public async execute(interaction: Interaction): Promise<void> {
if (interaction.inCachedGuild()) {
try {
if (interaction.isCommand()) {
console.log(`Command => ${(Date.now() - interaction.createdTimestamp) / 1000}`);
await this.handleCommand(interaction);
} else if (interaction.isButton()) {
console.log(`Button => ${(Date.now() - interaction.createdTimestamp) / 1000}`);
await interaction.deferReply({ ephemeral: true });
console.log(`Button interaction defered: ${(Date.now() - interaction.createdTimestamp) / 1000}`);
await this.handleButton(interaction);
} else if (interaction.isModalSubmit()) {
console.log(`Modal => ${(Date.now() - interaction.createdTimestamp) / 1000}`);
await interaction.deferReply({ ephemeral: false });
console.log(`Modal interaction defered: ${(Date.now() - interaction.createdTimestamp) / 1000}`);
await this.handleModalSubmit(interaction);
}
} catch (error) {
this.client.logger.error(error);
}
}
}
public async execute(interaction: Interaction): Promise<void> {
if (interaction.inCachedGuild()) {
try {
if (interaction.isCommand()) {
console.log(`Command => ${(Date.now() - interaction.createdTimestamp) / 1000}`);
await this.handleCommand(interaction);
} else if (interaction.isButton()) {
console.log(`Button => ${(Date.now() - interaction.createdTimestamp) / 1000}`);
await interaction.deferReply({ ephemeral: true });
console.log(`Button interaction defered: ${(Date.now() - interaction.createdTimestamp) / 1000}`);
await this.handleButton(interaction);
} else if (interaction.isModalSubmit()) {
console.log(`Modal => ${(Date.now() - interaction.createdTimestamp) / 1000}`);
await interaction.deferReply({ ephemeral: false });
console.log(`Modal interaction defered: ${(Date.now() - interaction.createdTimestamp) / 1000}`);
await this.handleModalSubmit(interaction);
}
} catch (error) {
this.client.logger.error(error);
}
}
}
I tried a version without the inCachedGuild() but same problem Times:
Button => 0.109
Button interaction defered: 0.386
Button => 0.107
Button interaction defered: 0.304
Button => 0.077
Button interaction defered: 0.267
Button => 0.129
Button interaction defered: 0.314
Button => 0.107
Button interaction defered: 0.511
Button => 0.106
Button interaction defered: 0.369
Button => 0.132
Button interaction defered: 0.479
Button => 0.076
Button interaction defered: 0.352
Button => 0.172
Button interaction defered: 0.447
Button => 0.153
Button interaction defered: 0.457
Command => 0.073
Modal => 0.111
Modal interaction defered: 1.328 <====
Command => 0.092
Modal => 0.108
Modal interaction defered: 0.397 <====
Command => 0.071
Modal => 0.098
Modal interaction defered: 0.385 <====
Command => 0.077
Modal => 0.136
Modal interaction defered: 0.53 <====
Command => 0.112
Modal => 0.187
Modal interaction defered: 6.142 <====
Button => 0.079
Button interaction defered: 0.371
Button => 0.084
Button interaction defered: 0.265
Command => 0.083
Modal => 0.092
{"code":10062,"level":"error","method":"POST","rawError":{"code":10062,"message":"Unknown interaction"},"requestBody":{"json":{"data":{},"type":5}},"status":404,"timestamp":"2024-06-01T11:56:15.837Z","url":"https://discord.com/api/v10/interactions/1246432059522547772/....../callback"}
Button => 0.105
Button interaction defered: 0.333
Button => 0.109
Button interaction defered: 0.386
Button => 0.107
Button interaction defered: 0.304
Button => 0.077
Button interaction defered: 0.267
Button => 0.129
Button interaction defered: 0.314
Button => 0.107
Button interaction defered: 0.511
Button => 0.106
Button interaction defered: 0.369
Button => 0.132
Button interaction defered: 0.479
Button => 0.076
Button interaction defered: 0.352
Button => 0.172
Button interaction defered: 0.447
Button => 0.153
Button interaction defered: 0.457
Command => 0.073
Modal => 0.111
Modal interaction defered: 1.328 <====
Command => 0.092
Modal => 0.108
Modal interaction defered: 0.397 <====
Command => 0.071
Modal => 0.098
Modal interaction defered: 0.385 <====
Command => 0.077
Modal => 0.136
Modal interaction defered: 0.53 <====
Command => 0.112
Modal => 0.187
Modal interaction defered: 6.142 <====
Button => 0.079
Button interaction defered: 0.371
Button => 0.084
Button interaction defered: 0.265
Command => 0.083
Modal => 0.092
{"code":10062,"level":"error","method":"POST","rawError":{"code":10062,"message":"Unknown interaction"},"requestBody":{"json":{"data":{},"type":5}},"status":404,"timestamp":"2024-06-01T11:56:15.837Z","url":"https://discord.com/api/v10/interactions/1246432059522547772/....../callback"}
Button => 0.105
Button interaction defered: 0.333
The problem is under node 18 and 20 and under versions 14.11 and 14.15.2 The problem is present on my dev machines (windows 11 / Ubuntu 24.04) and on my server (Debian 12)
5 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
gzordrai
gzordraiOP7mo ago
yes, but from there to goes from 0.53s to 6s it's still a little strange knowing that the interaction expires in the meantime knowing that this only happens for modals
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
gzordrai
gzordraiOP7mo ago
this is not logical, if this was an internet problem it would also happen for other ineractions except this only happens for modals if you look at the logs above the time for the buttons are in a regular and stable interval there is no big variation like for the modals
Want results from more Discord servers?
Add your server