From 51c6470d6b815443d46d5b82f9246194d8749ca9 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Mon, 23 Oct 2023 09:17:08 -0700 Subject: [PATCH] refactor/quality of life mongodb connection error --- package.json | 2 +- src/DayzRBot.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7873a3b..03a237f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dayzr-bot", - "version": "11.2.3", + "version": "11.2.4", "description": "A General Purpose Discord Bot for DayZ Nitrado Servers.", "main": "index.js", "nodemonConfig": { diff --git a/src/DayzRBot.js b/src/DayzRBot.js index 648a873..7143c08 100644 --- a/src/DayzRBot.js +++ b/src/DayzRBot.js @@ -293,7 +293,8 @@ class DayzRBot extends Client { this.databaseConnected = true; } catch (err) { databaselogs.attempts++; - this.error(`Failed to connect to mongodb (mongodb://${mongoURI.split('@')[1]}/${dbo}): attempt ${databaselogs.attempts} - ${err}`); + let db = (mongoURI.includes("@") ? mongoURI.split("@")[1] : mongoURI.split("//")[1]).endsWith("/") ? mongoURI.slice(0, -1) : mongoURI; + this.error(`Failed to connect to mongodb (mongodb://${db}/${dbo}): attempt ${databaselogs.attempts} - ${err}`); failed = true; }