Which errors do I have to handle for discord.js functions?

I would expect the docs to tell me which errors a function can throw but I can't find this info in the docs. Am I just blind or can I find this info somewhere else?
9 Replies
DaniDipp
DaniDipp3y ago
yeah, but how do I handle those?
Kinect3000
Kinect30003y ago
Try catch block and await it
DaniDipp
DaniDipp3y ago
The docs say Returns: Promise <Message> So it resolves to a message, but what is the type of the reject?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30003y ago
Mostly DiscordAPIError And DJSError
DaniDipp
DaniDipp3y ago
So for example on Message.delete(), I can get a DiscordAPIError for • The message doesn't exist anymore • The bot user doesn't have permission to delete the message • ??? Is anywhere documented what can go wrong?
Kinect3000
Kinect30003y ago
No, Discord doesn’t document that
DaniDipp
DaniDipp3y ago
damn ok thanks
Siris
Siris3y ago
Make your commands be executed within a try/catch block via a command handler that’ll aggregate all errors