From 4663886629875318f52206ad75a1c29db1b4bfd5 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sun, 25 Oct 2020 03:52:27 +0200 Subject: [PATCH] Also handle error 1001 gracefully --- src/bot.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/bot.js b/src/bot.js index 628c8d2..d65134a 100644 --- a/src/bot.js +++ b/src/bot.js @@ -27,11 +27,15 @@ const bot = new Eris.Client(config.token, { }, }); +// Eris allegedly handles these internally, so we can ignore them +const SAFE_TO_IGNORE_ERROR_CODES = [ + 1001, // "CloudFlare WebSocket proxy restarting" + 1006, // "Connection reset by peer" + "ECONNRESET", // Pretty much the same as above +]; + bot.on("error", err => { - if (err.code === 1006 || err.code === "ECONNRESET") { - // 1006 = "Connection reset by peer" - // ECONNRESET is similar - // Eris allegedly handles these internally, so we can ignore them + if (SAFE_TO_IGNORE_ERROR_CODES.includes(err.code)) { return; }