If you' re unlucky, you may have your application using discord. js crash with the following: events. js: 168 throw err; ^ Error: Uncaught, unspecified " error" event. ( [ object Object] ) at Client. starboard, where it interacts with messages listening to the messageReactionAdd event, check in the cache if the. I understand that the Discord API throws generic error codes ( such as in this case, 50013 [ Missing. Please describe the problem you are having in as much detail as possible: My server lost connection to the internet and on_ closed throw an error on emit( - 1) events. js: 165 throw err; Error: Uncaught, unspecified " error" event. The documentation for Client# error claims that the parameter will be of type Error: js. org/ # / docs/ main/ stable/ class/ Client? scrollTo= e- error.
At least when using ws, due to the way discord. js binds to it, the event. I' ve tried catching it in client disconnect and error events, yet they both don' t seem to be getting called. 4; Operating system: Windows 10; Priority this issue should have. The stacktrace contains: events. js: 188 throw err; ^ Error: Unhandled " error" event. at WebSocketConnection. onError ( / home/ yokuyuki/ spoilerbot/ node_ modules/ discord. js/ src/ client/ websocke. Okay, so this snippet of code will log, and also send a message to the channel where the error was caused.
You can remove the await xzbot. send_ message if you wouldn' t like it to send a message. import traceback. The reality of discord. js and many, many other libraries you will encounter, is that code is not executed one line at a time, one after. There' s a little trick we can use, however, to prevent complete crashes sometimes: Capturing the error event. js: 173 throw err; / / Unhandled ' error' event ^. Error [ ERR_ UNHANDLED_ ERROR] : Unhandled error. onError ( / home/ ec2- user/ kalina/ node_ modules/ discord. js/ src/ client/ websocket/ WebSocketConnection.