Test fix for more monitors?

This commit is contained in:
Christopher Cookman 2025-06-26 23:17:53 -06:00
parent 782fca6574
commit 06ebdb0459

View file

@ -48,9 +48,13 @@ function getStatus(input) {
let fieldParts = []; let fieldParts = [];
for (monitor of cat.monitors) { 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 const isOnline = Boolean(monitor.heartbeats[0].status); // Use Boolean() for clarity
console.log(`Monitor: ${monitor.name}, Status: ${status}`); console.log(`Monitor: ${monitor.name}, Status: ${isOnline}`);
const monitorText = `${status ? "<:online:1307359583785713744>" : "<:offline:1307359600592424971>"} ${monitor.name}\n`; 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 // Check if adding this monitor's text will exceed 1024 characters
if (fieldText.length + monitorText.length > 1024) { if (fieldText.length + monitorText.length > 1024) {
@ -61,10 +65,6 @@ function getStatus(input) {
// Otherwise, just add the monitor's text to the current field // Otherwise, just add the monitor's text to the current field
fieldText += monitorText; 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 // Push any remaining text in fieldText after processing all monitors