From ed9df5ff81393a79e7aacf31e537f82b7a27a191 Mon Sep 17 00:00:00 2001 From: koko210Serve Date: Sat, 28 Feb 2026 23:12:44 +0200 Subject: [PATCH] fix: resetServerMood variable scoping - originalText accessible in finally block --- bot/static/index.html | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bot/static/index.html b/bot/static/index.html index 01be1e6..01f30bc 100644 --- a/bot/static/index.html +++ b/bot/static/index.html @@ -2466,12 +2466,15 @@ async function resetServerMood(guildId) { const guildIdStr = String(guildId); console.log(`🎭 Using guildId as string: ${guildIdStr}`); + const button = document.querySelector(`button[onclick="resetServerMood('${guildIdStr}')"]`); + const originalText = button ? button.textContent : 'Reset'; + try { // Show loading state - const button = document.querySelector(`button[onclick="resetServerMood('${guildIdStr}')"]`); - const originalText = button.textContent; - button.textContent = 'Resetting...'; - button.disabled = true; + if (button) { + button.textContent = 'Resetting...'; + button.disabled = true; + } await apiCall(`/servers/${guildIdStr}/mood/reset`, 'POST'); showNotification(`Server mood reset to neutral`); @@ -2482,9 +2485,10 @@ async function resetServerMood(guildId) { showNotification(`Failed to reset mood: ${error}`, 'error'); } finally { // Restore button state - const button = document.querySelector(`button[onclick="resetServerMood('${guildIdStr}')"]`); - button.textContent = originalText; - button.disabled = false; + if (button) { + button.textContent = originalText; + button.disabled = false; + } } }