From d3fb0eacb6261403b1d014d803eb32ad2c54336b Mon Sep 17 00:00:00 2001 From: koko210Serve Date: Sat, 28 Feb 2026 23:26:02 +0200 Subject: [PATCH] fix: updateBedtimeRange variable scoping - originalText accessible in finally block --- bot/static/index.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bot/static/index.html b/bot/static/index.html index b72ba1f..1471042 100644 --- a/bot/static/index.html +++ b/bot/static/index.html @@ -2544,12 +2544,15 @@ async function updateBedtimeRange(guildId) { const [startHour, startMinute] = startTime.split(':').map(Number); const [endHour, endMinute] = endTime.split(':').map(Number); + const button = document.querySelector(`button[onclick="updateBedtimeRange('${guildIdStr}')"]`); + const originalText = button ? button.textContent : 'Update Bedtime Range'; + try { // Show loading state - const button = document.querySelector(`button[onclick="updateBedtimeRange('${guildIdStr}')"]`); - const originalText = button.textContent; - button.textContent = 'Updating...'; - button.disabled = true; + if (button) { + button.textContent = 'Updating...'; + button.disabled = true; + } // Send the update request const response = await fetch(`/servers/${guildIdStr}/bedtime-range`, { @@ -2579,9 +2582,8 @@ async function updateBedtimeRange(guildId) { } catch (error) { console.error('Failed to update bedtime range:', error); showNotification(error.message || 'Failed to update bedtime range', 'error'); - + } finally { // Restore button state - const button = document.querySelector(`button[onclick="updateBedtimeRange('${guildIdStr}')"]`); if (button) { button.textContent = originalText; button.disabled = false;