How best to handle `unknown interaction` on `deferReply`
Nomadding in Southeast Asia. My bot was working fine in Thailand but gets intermittent
unknown interaction
errors a lot here in Laos. Chased it for a couple of days looking at the usual reasons it occurs but it seems I'm getting it at the beginning of my handler where I do deferReply
which does not seem to be among the usual causes. Internet here is a bit laggy/bursty I suppose.
Is there a way to check whether my interaction
is still valid or can I only catch the exception when I try to use it?
If exception is the only way, what's the elegant way? I can't return from .catch()
since it's a closure. Putting it all in try
/catch
would lump this expected exception in with random exceptions which doesn't feel right. I don't think I can put the rest of the handler inside .then()
2 Replies
- 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!
i'm not quite expert level in js/ts yet. Not sure how to check for returning null from .catch
I've only used try/catch prior to this problem which I tracked down when I discovered .catch() which I don't yet have a feel for
just
let foo = await interaction.deferReply().catch(e => { return null; })
? seems that returns a InteractionResponse<boolean>
i don't
i don't fully grok the ramifications. by returning null
i change the inferred type into a nullable aka InteractionResponse<boolean> | null
and i don't need to care what an InteractionResponse or the boolean
in it mean?
annoyingly today's café is less laggy/bursty so can't test it so far