Test fix for more monitors?
This commit is contained in:
parent
782fca6574
commit
06ebdb0459
20
index.js
20
index.js
|
@ -48,10 +48,14 @@ 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) {
|
||||||
// Push the current field text and start a new field
|
// 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
|
// 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
|
||||||
if (fieldText.trim()) {
|
if (fieldText.trim()) {
|
||||||
fieldParts.push(fieldText.trim());
|
fieldParts.push(fieldText.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now, add each part as a separate field
|
// Now, add each part as a separate field
|
||||||
for (let i = 0; i < fieldParts.length; i++) {
|
for (let i = 0; i < fieldParts.length; i++) {
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
|
|
Loading…
Reference in a new issue