unknown interaction when trying to defer interaction

if deferring an interaction has a chance to fail how do i ensure that interactions are ALWAYS responded too?
7 Replies
d.js toolkit
d.js toolkit16mo 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!
Squid
Squid16mo ago
If the deferReply() throws Unknown Interaction, that means Discord received the request 3 or more seconds since the interaction was created, so the interaction has now expired and cannot be acknowledged by any means now The closest you could do as a failsafe is to catch the error, and if it's an unknown interaction error, just do interaction.channel.send(...) with something
capy
capyOP16mo ago
but it definitely doesn't take 3 seconds
oxi
oxi16mo ago
Are you trying to edit an empheral reply? iirc you can only update
capy
capyOP16mo ago
yes i do #editReply later
Squid
Squid16mo ago
instanceof can be a relatively intensive check, so you should probably replace that whole if statement with if (!interaction.inCachedGuild()) return; That should save you at least a few milliseconds, and with situations like this, every optimization counts Otherwise, it's probably a network issue/hardware shortcoming instead of any problem with your code
capy
capyOP16mo ago
okay thank you
Want results from more Discord servers?
Add your server