something had to fail
This commit is contained in:
parent
d0ee41b512
commit
39c12f7d58
1 changed files with 7 additions and 3 deletions
10
index.js
10
index.js
|
@ -1,5 +1,5 @@
|
||||||
const {extend: createGotClient} = require('got');
|
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 chalk = require('chalk');
|
||||||
const WS = require('ws');
|
const WS = require('ws');
|
||||||
const Config = require('./config.json');
|
const Config = require('./config.json');
|
||||||
|
@ -37,7 +37,7 @@ const fetchList = async (listID) => {
|
||||||
throw new Error('Unexpected error occurred!');
|
throw new Error('Unexpected error occurred!');
|
||||||
}
|
}
|
||||||
|
|
||||||
const listData = await pnslClient(`BotLists/${listID}`);
|
const {body: listData} = await pnslClient(`BotLists/${listID}`);
|
||||||
|
|
||||||
const listMeta = JSON.parse(listMetaBody);
|
const listMeta = JSON.parse(listMetaBody);
|
||||||
return {listMeta, listData};
|
return {listMeta, listData};
|
||||||
|
@ -145,6 +145,10 @@ pnslWebSocket.on('message', async (data) => {
|
||||||
clients[i].connect();
|
clients[i].connect();
|
||||||
return console.error(`Error in client ${i} -> ${error.name} || ${error.message}`);
|
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);
|
console.error(error);
|
||||||
});
|
});
|
||||||
return await new Promise((resolve) => clients[i].on('ready', () => resolve()));
|
return await new Promise((resolve) => clients[i].on('ready', () => resolve()));
|
||||||
|
@ -179,7 +183,7 @@ pnslWebSocket.on('message', async (data) => {
|
||||||
}
|
}
|
||||||
const data = await fetchList(listID);
|
const data = await fetchList(listID);
|
||||||
await runList(data.listData, listID, channel || channelName);
|
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) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return clients[0].say(Config.Username, `Error Occurred! ${error.message}`);
|
return clients[0].say(Config.Username, `Error Occurred! ${error.message}`);
|
||||||
|
|
Loading…
Reference in a new issue