something had to fail

This commit is contained in:
Leppunen 2020-12-22 08:40:02 +02:00
parent d0ee41b512
commit 39c12f7d58

View file

@ -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}`);