#Wrong error code

37 messages · Page 1 of 1 (latest)

rose thorn
#

So lately I have this issue that the interactionCreate event is fired really late sometimes, like 5-10 seconds after the interaction was sent. While this is annoying, I have code in place to deal with this so this is not the problem I am having.
My problem is the following: If I attempt to call interaction.reply, it responds with error code 10062 (Unknown Interaction).
This is completely correct and expected behavior. But if I attempt to followUp right after the reply, it will show error code InteractionNotReplied. While this is technically true, I believe Unknown Interaction is the correct error to throw here since InteractionNotReplied makes it sound like the interaction is still valid and repliable and I just didn‘t reply to it, which led to me bughunting a bug that didn‘t exist.

runic meadow
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

wide rain
mint stratus
#

That is the correct error, you did not successfully reply to the interaction, and followups will not work

#

also, in the event this happens, you'd get an unknown interaction followed by the not replied error

rose thorn
wide rain
#

Don't think it's possible to know that without actually following up

mint stratus
#

well, I don't think I completely agreed with guarding the library side when it was implemented, but the interaction not replied error is thrown by the lib before it hits the api, and the api throws the unknown interaction error. By throwing the not replied error you are not wasting an api call

rose thorn
rose thorn
#

was just really annoying to kind of be misled by what the issue was due to how the error makes it sound, but yeah

mint stratus
#

in your case, though not recommended, you can actually set interaction.replied = true to avoid this

rose thorn
#

i don‘t need to, because the same handler that handles the reply should have also handled the followUp. I just had some left over code that called followUp directly

mint stratus
#

ah

rose thorn
#

This is the handler, if you are interested btw

mint stratus
#

yeah unfortunately doing low level stuff like that breaks the library flow to a degree which sucks but is how the library is currently built

#

wait, you aren't doing low level stuff, why isn't the lib setting replied true for you

rose thorn
# rose thorn This is the handler, if you are interested btw

basically the idea is, i just pass the interaction and the options, then i can optionally put type 'update' if i want to update instead of reply, and a message id if i want to edit rather than followUp in case a reply/update has already been sent. This is followed up by a bunch of catch cases that make sure a normal message is sent or normal message is edited in case there was some problem with the interaction (like it being unknown/outdated)

#

This makes it easier for me because I have such a complex system where the same action can be done from different places that sometimes requires a reply, sometimes an editReply, and sometimes an update, or sometimes a reply and sometimes a followUp, so this way I'm making it kind of easy for myself what I want to do, including editing a followUp message, while also having built-in handlers when things go wrong

mint stratus
#

oh you were catching an error for unknown interaction but not followup

#

honestly, I'd be more interested at looking into why you are receiving interactions late so that you can remove the backup handling there and actually consider unknown interactions as errors

rose thorn
rose thorn
#

but even if it just happens once a day, sending a reply over sending nothing is always the preferred way for me, because sometimes a user thinking that the bot hasn't taken in their command or the bot waiting for a user input (via clicking a button) that isn't coming is just a way bigger hassle to deal with than this

mint stratus
#

I'd still log the fact that the interaction failed to sentry or whatever

#

Are you sure that the interaction create itself is delayed btw?

rose thorn
#

i actually do but it doesn't give a user-facing error so when i received an error ticket about the followUp failing, i didn't notice that there was another error attached to it

mint stratus
#

ooh

rose thorn
#

and to me the more logical explanation was me just somehow not awaiting my main code properly

#

so i wasted a lot of time on testing that until i randomly failed an interaction

mint stratus
#

we're investigating increased unknown interaction errors with discord devs right now too, but that PR linked above should help with that a bunch too

rose thorn
#

niceee

#

but yeah, it's all good then :) it was an unfortunate series of events leading to this being a very unnecessarily frustrating bug hunting session so i thought i'd bring this up

#

but if it can't be changed easily it doesn't matter too much

mint stratus
#

yeah, I chase those types of bugs sometimes and I know its pretty frustrating. In this case I think not hitting the API outweighs most of it, but maybe the interaction not replied error could be improved to help

rose thorn
#

i agree to both of these yes