From 576adfebbe86eb915cbf4bee5f6870bcf43727ce Mon Sep 17 00:00:00 2001 From: Yui Date: Thu, 26 Jan 2023 19:26:50 +0100 Subject: [PATCH 1/2] Fix 3 errors Reply with embedded link in ticket: Fixed /support command "Invalid Form Body" error: Fixed ECONNRESET: fixed? - trying to prevent by keeping the connection alive --- bot/core/DatabaseManager.js | 12 +++++++++--- bot/core/TicketsManager.js | 2 +- bot/core/Utils.js | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bot/core/DatabaseManager.js b/bot/core/DatabaseManager.js index 7d6f714..ced9c72 100644 --- a/bot/core/DatabaseManager.js +++ b/bot/core/DatabaseManager.js @@ -1,8 +1,14 @@ const mysql = require("mysql2"); -module.exports = mysql.createConnection({ +// changing one connection to a pool for better performance and to prevent the connection from being closed by the database +module.exports = mysql.createPool({ host : process.env.DATABASE_HOST, user : process.env.DATABASE_USER, password : process.env.DATABASE_PASSWORD, - database : process.env.DATABASE_DATABASE -}); \ No newline at end of file + database : process.env.DATABASE_DATABASE, + multipleStatements: true, + // keepAlive to try to prevent the connection from being closed by the database + keepAlive: true, + keepAliveInitialDelay: 28799 // 1s less than 8 hours | default timeout when no activity is detected is 8 hours +}); + diff --git a/bot/core/TicketsManager.js b/bot/core/TicketsManager.js index 7ebc07d..2478737 100644 --- a/bot/core/TicketsManager.js +++ b/bot/core/TicketsManager.js @@ -112,7 +112,7 @@ class TicketsManager { style: 2, min_length: 1, max_length: 1000, - value: comment?.slice?.(0, 990) || "", + value: comment?.slice?.(0, 990) || null, placeholder: "Z. B. \"Der Nutzer hat in #laberecke beleidigt\" oder \"Wie erhalte ich die Sub Rolle?\"", required: true }], }, { type: 1, components: [{ diff --git a/bot/core/Utils.js b/bot/core/Utils.js index b8dc7f6..23453ee 100644 --- a/bot/core/Utils.js +++ b/bot/core/Utils.js @@ -8,7 +8,9 @@ class Utils { finalString += message?.content; if (message?.embeds?.length > 0) - finalString += "\n" + this.getEmbedsAsString(message.embeds); + //finalString += "\n" + this.getEmbedsAsString(message.embeds); + // When links are sent and turn into an embed, the embeds array will contain the link as a string, which is the easiest way to save it + finalString += "\n" + message?.embeds?.url?.toString(); if (message?.attachments?.size > 0) finalString += "\n" + message?.attachments?.map(a => a?.url)?.join(" "); From cdc8cf620d0b29bcedd996b2552f8f389703d693 Mon Sep 17 00:00:00 2001 From: Yui Date: Thu, 26 Jan 2023 21:03:18 +0100 Subject: [PATCH 2/2] Update DatabaseManager.js --- bot/core/DatabaseManager.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bot/core/DatabaseManager.js b/bot/core/DatabaseManager.js index ced9c72..c2119af 100644 --- a/bot/core/DatabaseManager.js +++ b/bot/core/DatabaseManager.js @@ -8,7 +8,6 @@ module.exports = mysql.createPool({ database : process.env.DATABASE_DATABASE, multipleStatements: true, // keepAlive to try to prevent the connection from being closed by the database - keepAlive: true, keepAliveInitialDelay: 28799 // 1s less than 8 hours | default timeout when no activity is detected is 8 hours });