diff --git a/index.js b/index.js index 88d3adf..0975185 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ const {extend: createGotClient} = require('got'); -const {ConnectionError, SayError, TimeoutError, ChatClient} = require('dank-twitch-irc'); +const {ConnectionError, SayError, TimeoutError, UserBanError, ChatClient} = require('dank-twitch-irc'); const chalk = require('chalk'); const WS = require('ws'); const Config = require('./config.json'); @@ -143,6 +143,9 @@ pnslWebSocket.on('message', async (data) => { }); clients[i].on('error', (error) => { if (error instanceof SayError) return; + if (error instanceof UserBanError) { + return console.warn(`Failed to ban user ${error.username} from ${error.channelname}`); + } if (error instanceof ConnectionError) { if (clients[i].ready) { return; @@ -206,3 +209,13 @@ pnslWebSocket.on('message', async (data) => { } }, pingInterval); })(); + +process + .on('unhandledRejection', (err) => { + if (err.name === 'SayError') return + console.error(`${chalk.red('[UnhandledRejection]')} || [${err.name}] ${err} - ${err.stack}`); + }) + .on('uncaughtException', (err) => { + console.error(`${chalk.red('[UncaughtException]')} || ${err.message}`); + process.exit(0); + }); \ No newline at end of file