From 07297c761c364eb86248eb96237185e28baa26cf Mon Sep 17 00:00:00 2001 From: "chris062689@gmail.com" Date: Thu, 6 Sep 2018 21:10:21 -0400 Subject: [PATCH] Added client.on for errors, warnings, etc. Errors will force reset the bot. --- src/server.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/server.js b/src/server.js index b05f7d3..3e51522 100644 --- a/src/server.js +++ b/src/server.js @@ -41,6 +41,24 @@ client.on('ready', () => { logger.info('Bot is now online and connected to server.'); }); +client.on('error', (x) => { + logger.error(x) + logger.error('Restarting process.') + process.exit(1) +}) +client.on('warn', (x) => { + logger.warn(x) +}) + +client.on('debug', (x) => null) + +client.on('disconnect', () => { + logger.warn('Disconnected from Discord server.'); +}) +client.on('reconnecting', () => { + logger.warn('Reconnecting...'); +}) + client.on('guildMemberAdd', (member) => { member.addRole(process.env.DISCORD_RULES_ROLE); state.stats.joins += 1;