From 08a729e270de18b74b1d357054f0d981daee03fc Mon Sep 17 00:00:00 2001 From: baz Date: Mon, 2 Dec 2024 19:34:01 +0000 Subject: [PATCH] Add some error checking --- commands/100-games/wrapped.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/commands/100-games/wrapped.js b/commands/100-games/wrapped.js index d42c46e..c862247 100644 --- a/commands/100-games/wrapped.js +++ b/commands/100-games/wrapped.js @@ -264,7 +264,10 @@ async function GetFavouriteGenres() { string = string.concat(` ${sortedCounts[genre][0]} (${sortedCounts[genre][1]} games),`); } } - string = string.slice(1, -1); + + if (string.length > 1) { + string = string.slice(1, -1); + } return string; } @@ -301,7 +304,10 @@ async function GetFavouriteDevelopers() { string = string.concat(` ${sortedCounts[developer][0]} (${sortedCounts[developer][1] } games),`); } } - string = string.slice(1, -1); + + if (string.length > 1) { + string = string.slice(1, -1); + } return string; } @@ -339,7 +345,10 @@ async function GetFavouritePublishers() { string = string.concat(` ${sortedCounts[publisher][0]} (${sortedCounts[publisher][1]} games),`); } } - string = string.slice(1, -1); + + if (string.length > 1) { + string = string.slice(1, -1); + } return string; }