gzordrai
gzordrai
DIAdiscord.js - Imagine an app
Created by gzordrai on 6/1/2024 in #djs-questions
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)
8 replies
DIAdiscord.js - Imagine an app
Created by gzordrai on 6/17/2023 in #djs-questions
Unknow interaction
Hello, I've been stuck on the UnknowInteraction error returned by my code for several weeks. The problem is that I can't reproduce the bug, it happens randomly and despite many tries I still can't find the source of the problem. Discord.js:
unitybot@1.0.0 /home/debian/UnityBot
└── discord.js@14.11.0
unitybot@1.0.0 /home/debian/UnityBot
└── discord.js@14.11.0
Node:
v16.18.0
v16.18.0
Env:
_,met$$$$$gg. debian@vps-e32defb0
,g$$$$$$$$$$$$$$$P. -------------------
,g$$P" """Y$$.". OS: Debian GNU/Linux 10 (buster) x86_64
,$$P' `$$$. Host: OpenStack Nova 19.3.2
',$$P ,ggs. `$$b: Kernel: 4.19.0-22-cloud-amd64
`d$$' ,$P"' . $$$ Uptime: 198 days, 23 hours, 9 mins
$$P d$' , $$P Packages: 643 (dpkg)
$$: $$. - ,d$$' Shell: bash 5.0.3
$$; Y$b._ _,d$P' Terminal: /dev/pts/0
Y$$. `.`"Y$$$$P"' CPU: Intel (Haswell, no TSX) (1) @ 2.399GHz
`$$b "-.__ Memory: 232MiB / 1949MiB
`Y$$
`Y$$.
`$$b.
`Y$$b.
`"Y$b._
_,met$$$$$gg. debian@vps-e32defb0
,g$$$$$$$$$$$$$$$P. -------------------
,g$$P" """Y$$.". OS: Debian GNU/Linux 10 (buster) x86_64
,$$P' `$$$. Host: OpenStack Nova 19.3.2
',$$P ,ggs. `$$b: Kernel: 4.19.0-22-cloud-amd64
`d$$' ,$P"' . $$$ Uptime: 198 days, 23 hours, 9 mins
$$P d$' , $$P Packages: 643 (dpkg)
$$: $$. - ,d$$' Shell: bash 5.0.3
$$; Y$b._ _,d$P' Terminal: /dev/pts/0
Y$$. `.`"Y$$$$P"' CPU: Intel (Haswell, no TSX) (1) @ 2.399GHz
`$$b "-.__ Memory: 232MiB / 1949MiB
`Y$$
`Y$$.
`$$b.
`Y$$b.
`"Y$b._
The code causing the error: https://github.com/gzordrai/UnityBot/blob/main/src/events/interactionCreate.ts
8 replies