NodeJS Bot Error

Status
This thread has been locked.

Satan

Devil#0666
Supreme
Feedback score
52
Posts
3,667
Reactions
1,442
Resources
0
So the discord bot works fine, but it randomly just crashes?

I'll provide code in DMs or PM, its 2 files. Heres the error, any NodeJS devs know how to fix this?

Code:
events.js:188
      throw err;
      ^

Error: Unhandled "error" event. ([object Object])
    at CommandoClient.emit (events.js:186:19)
    at WebSocketConnection.onError (/root/DiscordBots/Toggle/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:374:17)
    at WebSocket.onError (/root/DiscordBots/Toggle/node_modules/ws/lib/event-target.js:128:16)
    at emitOne (events.js:116:13)
    at WebSocket.emit (events.js:211:7)
    at _receiver.cleanup (/root/DiscordBots/Toggle/node_modules/ws/lib/websocket.js:211:14)
    at Receiver.cleanup (/root/DiscordBots/Toggle/node_modules/ws/lib/receiver.js:557:13)
    at WebSocket.finalize (/root/DiscordBots/Toggle/node_modules/ws/lib/websocket.js:206:20)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Caliban

Professional Idiot
Premium
Feedback score
0
Posts
144
Reactions
62
Resources
0
where is your bot hosted?
 

acollierr17

Supreme
Feedback score
7
Posts
85
Reactions
18
Resources
0
I would start by adding the error event provided by discord.js. You can start as simple as what I provided below. I'm not exactly sure how your code is set up, so I'm going to assume you have all your events in the index.js or whatever your main file is called:
Code:
client.on("error", () => console.error);
Documentation: https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-error
 
Last edited:
Status
This thread has been locked.
Top