From e1786a62fbc196d08016df2d6a247fb0f734b0e6 Mon Sep 17 00:00:00 2001 From: HRiggs Date: Mon, 6 Oct 2025 00:56:47 -0400 Subject: [PATCH] fix 2 --- Bot/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Bot/index.js b/Bot/index.js index 4e7c4a9..52a6bab 100644 --- a/Bot/index.js +++ b/Bot/index.js @@ -54,9 +54,14 @@ async function updateMessages() { return; } + console.log(`Fetching from backend: ${config.backendUrl}`); const response = await axios.get(config.backendUrl); const monitors = response.data; + console.log('Backend response status:', response.status); + console.log('Backend response data type:', typeof monitors); + console.log('Backend response data:', JSON.stringify(monitors).substring(0, 500) + '...'); + // Check if the backend returned an error if (monitors.error) { console.error('Backend API error:', monitors.message); @@ -66,6 +71,7 @@ async function updateMessages() { // Ensure monitors is an array if (!Array.isArray(monitors)) { console.error('Backend returned invalid data format:', typeof monitors); + console.error('Expected array, got:', monitors); return; } @@ -91,8 +97,14 @@ async function updateMessages() { console.log(`Web Services: ${webServicesMonitors.length}, Infrastructure: ${infrastructureMonitors.length}, Network: ${networkMonitors.length}`); await sendMonitorsMessage(channel, 'Web Services', webServicesMonitors); - // await sendMonitorsMessage(channel, 'Infrastructure', infrastructureMonitors); + // await sendMonitorsMessage(channel, 'Infrastructure', infrastructureMonitors); //await sendMonitorsMessage(channel, 'Network', networkMonitors); + + // Send a test message if no monitors found + if (webServicesMonitors.length === 0) { + console.log('No monitors found, sending test message'); + await channel.send('🔧 Bot is running but no monitors found. Check backend configuration.'); + } } catch (error) { console.error('Error updating messages:', error); @@ -110,6 +122,8 @@ async function updateMessages() { } async function sendMonitorsMessage(channel, category, monitors) { + console.log(`Processing ${category}: ${monitors.length} monitors`); + let description = monitors.map(monitor => { let statusEmoji = ''; switch (monitor.status) { @@ -131,9 +145,12 @@ async function sendMonitorsMessage(channel, category, monitors) { return `${statusEmoji} | ${monitor.monitor_name}`; }).join('\n'); + console.log(`Generated description for ${category}: "${description}"`); + // Ensure description is not empty (Discord.js validation requirement) if (!description || description.trim() === '') { description = `No ${category.toLowerCase()} monitors found.`; + console.log(`Empty description, using fallback: "${description}"`); } let embed = new EmbedBuilder()