Dragory / modmailbot

Modmail Bot is a bot for Discord that makes it easier for users to contact moderators and admins for help.
MIT License
708 stars 703 forks source link

Bot randomly goes offline #200

Closed sleepymanakete closed 5 years ago

sleepymanakete commented 5 years ago

My bot goes offline randomly and I have to start it up again. Message I get in cmd:


      throw er; // Unhandled 'error' event
      ^

Error: Unhandled "error" event. ([object Object])
    at CommandClient.emit (events.js:186:19)
    at Shard.emit
(/home/lailah/Downloads/modmailbot-master/node_modules/eris/lib/gateway/Shard.js:1888:26)
    at WebSocket.ws.onerror
(/home/lailah/Downloads/modmailbot-master/node_modules/eris/lib/gateway/Shard.js:1612:18)
    at WebSocket.onError
(/home/lailah/Downloads/modmailbot-master/node_modules/ws/lib/event-target.js:128:16)
    at emitOne (events.js:116:13)
    at WebSocket.emit (events.js:211:7)
    at abortHandshake
(/home/lailah/Downloads/modmailbot-master/node_modules/ws/lib/websocket.js:648:15)
    at WebSocket.terminate
(/home/lailah/Downloads/modmailbot-master/node_modules/ws/lib/websocket.js:348:14)
    at Shard.disconnect
(/home/lailah/Downloads/modmailbot-master/node_modules/eris/lib/gateway/Shard.js:101:25)
    at Timeout.setTimeout [as _onTimeout]
(/home/lailah/Downloads/modmailbot-master/node_modules/eris/lib/gateway/Shard.js:1660:22)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)```
Ragnarok345 commented 5 years ago

Yeah, that used to happen a lot, but Mikka fixed that issue a while ago, on September 20th or somewhere around there. Do you have the most current version of the bot?

sleepymanakete commented 5 years ago

yup, i have the lastest version

Ragnarok345 commented 5 years ago

Hmm. I don't know then. Are you familiar with pm2? I literally just figured it out maybe half an hour ago. It would make it so that if it crashes like that again, or if your internet goes offline and comes back up, it'll automatically restart the bot for you. I just got it working, tested it twice, and it's great so far.

sleepymanakete commented 5 years ago

Can you please explain what pm2 is?

Dragory commented 5 years ago

PM2 is a process manager which, among other things, can auto-restart the bot for you if it crashes. Ideally the bot wouldn't crash at all, of course, but pm2 helps when it does.

For modmail, to use pm2 (after installing it), you would basically just replace step 7 in Setup with the command pm2 start --name modmail npm -- start and then, if you need to restart the bot later (e.g. after updating it), you'd run pm2 restart modmail.

sleepymanakete commented 5 years ago

ahh, thank you!!