From 06ebdb045959e0e843a0a524ee6851324c4fbd86 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Thu, 26 Jun 2025 23:17:53 -0600 Subject: [PATCH] Test fix for more monitors? --- index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index d8a6c9f..f9076e4 100644 --- a/index.js +++ b/index.js @@ -48,10 +48,14 @@ function getStatus(input) { let fieldParts = []; for (monitor of cat.monitors) { - const status = new Boolean(monitor.heartbeats[0].status); // Turn it into a boolean because 0 and 1 are not always reliable in JS - console.log(`Monitor: ${monitor.name}, Status: ${status}`); - const monitorText = `${status ? "<:online:1307359583785713744>" : "<:offline:1307359600592424971>"} ${monitor.name}\n`; - + const isOnline = Boolean(monitor.heartbeats[0].status); // Use Boolean() for clarity + console.log(`Monitor: ${monitor.name}, Status: ${isOnline}`); + const monitorText = `${isOnline ? "<:online:1307359583785713744>" : "<:offline:1307359600592424971>"} ${monitor.name}\n`; + + // If the monitor is offline, increment the offline count + if (!isOnline) offline++; + total++; + // Check if adding this monitor's text will exceed 1024 characters if (fieldText.length + monitorText.length > 1024) { // Push the current field text and start a new field @@ -61,17 +65,13 @@ function getStatus(input) { // Otherwise, just add the monitor's text to the current field fieldText += monitorText; } - - // If the monitor is offline, increment the offline count - if (!status) offline++; - total++; } - + // Push any remaining text in fieldText after processing all monitors if (fieldText.trim()) { fieldParts.push(fieldText.trim()); } - + // Now, add each part as a separate field for (let i = 0; i < fieldParts.length; i++) { embed.fields.push({