#How to handle modal submit timeout error in outer catch?
6 messages · Page 1 of 1 (latest)
"discord.js": "^14.5.0",
v16.18.0```
yeah because a slash command is never gonna be a modal submit interaction
show your entire code
There's too much abstracted code around it to show the full code, no one will read it all. I'll try to simplify it though.
The main question is how do you reply to an interaction if there was a modal timeout error?
If I catch the timeout error from await interaction.awaitModalSubmit locally or in an outer catch, interaction.editReply throws this error: DiscordAPIError[10008]: Unknown Message
interactionCreate event. :
try {
// exported slash command object containing a run method
await foundModularSlashCommand.run(interaction);
}
catch (e) {
if (interaction.isRepliable()) {
if (interaction.deferred || interaction.replied) {
return await interaction.editReply({ content: e.message, components: [] });
} else {
return await interaction.reply(e.message);
}
}
}
This is inside the custom run method of the slash command that is being executed.
Even if I wrap the awaitModalSubmit in a try catch I cant interaction.editReply because it throws the above mentioned error:
// This all works if no modal timeout
await interaction.showModal(modal);
const modalSubmission = await interaction.awaitModalSubmit({
filter: (interaction) => interaction.customId === modalId,
time: 6000,
});
await modalSubmission.reply('Success.');
When I try to reply in the outer catch, this is the code that is running:
if (interaction.isRepliable()) {
if (interaction.deferred || interaction.replied) {
return await interaction.editReply({ content: e.message, components: [] });
}