From f7230ec0fb80f522e0b2204224bc8d4971c034e6 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Thu, 1 Jun 2023 18:31:02 -0400 Subject: [PATCH] Trying error handling DO NOT PUSH 2 PROD --- modules/functions.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/functions.js b/modules/functions.js index 9027ccf..47fe244 100755 --- a/modules/functions.js +++ b/modules/functions.js @@ -755,7 +755,11 @@ const functions = { await functions.roles.takeRole(interaction.member, role); status = "Removed the fruit role."; } else { - await functions.roles.giveRole(interaction.member, role); + await functions.roles.giveRole(interaction.member, role).catch(e => { + const errorId = functions.generateErrorId(); + console.error(errorId + " " + e); + status = `Error adding the fruit role: ${errorId}`; + }); status = "Added the fruit role."; } return functions.builders.embed(status); @@ -1064,6 +1068,18 @@ const functions = { } else { throw "Guild doesn't exist in database!"; } + }, + generateErrorId() { + const digitCount = 10; + const digits = []; + for (let i = 0; i < digitCount; i++) { + const randBase = Math.random(); + const randNumRaw = randBase * 10; + const randNumRound = Math.floor(randNumRaw); + digits.push(randNumRound); + } + const errorId = digits.join(""); + return errorId; } };