fix: resetServerMood variable scoping - originalText accessible in finally block
This commit is contained in:
@@ -2466,12 +2466,15 @@ async function resetServerMood(guildId) {
|
|||||||
const guildIdStr = String(guildId);
|
const guildIdStr = String(guildId);
|
||||||
console.log(`🎭 Using guildId as string: ${guildIdStr}`);
|
console.log(`🎭 Using guildId as string: ${guildIdStr}`);
|
||||||
|
|
||||||
|
const button = document.querySelector(`button[onclick="resetServerMood('${guildIdStr}')"]`);
|
||||||
|
const originalText = button ? button.textContent : 'Reset';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Show loading state
|
// Show loading state
|
||||||
const button = document.querySelector(`button[onclick="resetServerMood('${guildIdStr}')"]`);
|
if (button) {
|
||||||
const originalText = button.textContent;
|
|
||||||
button.textContent = 'Resetting...';
|
button.textContent = 'Resetting...';
|
||||||
button.disabled = true;
|
button.disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
await apiCall(`/servers/${guildIdStr}/mood/reset`, 'POST');
|
await apiCall(`/servers/${guildIdStr}/mood/reset`, 'POST');
|
||||||
showNotification(`Server mood reset to neutral`);
|
showNotification(`Server mood reset to neutral`);
|
||||||
@@ -2482,11 +2485,12 @@ async function resetServerMood(guildId) {
|
|||||||
showNotification(`Failed to reset mood: ${error}`, 'error');
|
showNotification(`Failed to reset mood: ${error}`, 'error');
|
||||||
} finally {
|
} finally {
|
||||||
// Restore button state
|
// Restore button state
|
||||||
const button = document.querySelector(`button[onclick="resetServerMood('${guildIdStr}')"]`);
|
if (button) {
|
||||||
button.textContent = originalText;
|
button.textContent = originalText;
|
||||||
button.disabled = false;
|
button.disabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function updateBedtimeRange(guildId) {
|
async function updateBedtimeRange(guildId) {
|
||||||
console.log(`⏰ updateBedtimeRange called with guildId: ${guildId}`);
|
console.log(`⏰ updateBedtimeRange called with guildId: ${guildId}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user