Checking to make sure a message still exist (Unknown Message Errors)
How can I check if a message still exists after I've gotten the message? I keep getting Unknown Message errors because I'm trying to react to a message that no longer exists. The problem is that my bot thinks it does exist cause it has the message stored in its cache as a variable. What should I do? Is there a way to verify that the message still exists before I try to react 🤷‍♂️
6 Replies
• 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.Try to react to the message and catch the rejected. If you want, you can fetch the message in the catch to see if it's truly deleted
Well this won't resolve the problem because even if I do catch it, I'll still get an error because its a Discord API error. I was hoping more for a way to just stop the error from happening in the first place.
I think he meant that
the catch does't do anything in this case and it still throws new DiscordAPIError.
I encountered this recently for similar problems, but I found other solutions I believe not applicable here, sorry.
Well, do you add await before it? A try catch block will catch rejected promises and errors
well, the best solution I got for those kinds of issues is
this fetches message from around the message you are trying to react to, and if it still exist, the collection contains the message so you can react.
However, there can still be some timing edge cases where the fetched data will already be outdated which will cause errors like Qjuh said.