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.
#Wrong error code
37 messages · Page 1 of 1 (latest)
• 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.
Do you have a large bot? If so, I think https://github.com/discordjs/discord.js/pull/8996 may fix it
i do not, 380 servers
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
but i feel like the fact that its an unknown interaction should take priority over it being not replied. both are true but its clear with the first one that the problem is the interaction not being repliable anymore
Don't think it's possible to know that without actually following up
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
I have a handler for this so i didn‘t get that first error. the second error led me to believe the followUp was happening without me ever replying, rather than the interaction being old
fair enough, that‘s a good point
was just really annoying to kind of be misled by what the issue was due to how the error makes it sound, but yeah
in your case, though not recommended, you can actually set interaction.replied = true to avoid this
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
ah
This is the handler, if you are interested btw
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
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
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
exactly, and ofc the followUp call within this handler won't be called when the original interaction doesn't get replied because the check for whether it was replied will not pass, but because i used followUp outside of this handler accidentally as old left-over code, it threw an error that was very confusing
- for some reason since january 1st it really increased, i heard from others that they have the same issue
- my bot is running on a german server, and idk if its just german internet being famously slow or it having to do with the distance to america, but yeah for some reason this is just a bigger problem
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
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?
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
ooh
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
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
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
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
i agree to both of these yes