From 39c12f7d580461a53039d069d4cf4c1116085e77 Mon Sep 17 00:00:00 2001 From: Leppunen Date: Tue, 22 Dec 2020 08:40:02 +0200 Subject: [PATCH] something had to fail --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index e1f3885..85ed56e 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ const {extend: createGotClient} = require('got'); -const {ConnectionError, SayError, ChatClient} = require('dank-twitch-irc'); +const {ConnectionError, SayError, PingTimeoutError, ChatClient} = require('dank-twitch-irc'); const chalk = require('chalk'); const WS = require('ws'); const Config = require('./config.json'); @@ -37,7 +37,7 @@ const fetchList = async (listID) => { throw new Error('Unexpected error occurred!'); } - const listData = await pnslClient(`BotLists/${listID}`); + const {body: listData} = await pnslClient(`BotLists/${listID}`); const listMeta = JSON.parse(listMetaBody); return {listMeta, listData}; @@ -145,6 +145,10 @@ pnslWebSocket.on('message', async (data) => { clients[i].connect(); return console.error(`Error in client ${i} -> ${error.name} || ${error.message}`); } + if (error instanceof PingTimeoutError) { + clients[i].connect(); + return console.error(`Ping Error in client ${i} -> ${error.name} || ${error.message}`); + } console.error(error); }); return await new Promise((resolve) => clients[i].on('ready', () => resolve())); @@ -179,7 +183,7 @@ pnslWebSocket.on('message', async (data) => { } const data = await fetchList(listID); await runList(data.listData, listID, channel || channelName); - clients[0].say(Config.Username, `List ${listID} executed successfully on channel ${channel}`); + clients[0].say(Config.Username, `List ${listID} executed successfully on channel ${channel || channelName}`); } catch (error) { console.error(error); return clients[0].say(Config.Username, `Error Occurred! ${error.message}`);