diff --git a/bot/static/index.html b/bot/static/index.html index ee00329..8c316ad 100644 --- a/bot/static/index.html +++ b/bot/static/index.html @@ -1150,8 +1150,12 @@ async function populateServerDropdowns() { manualServerSelect.innerHTML = ''; customPromptServerSelect.innerHTML = ''; + console.log('🎭 Populating server dropdowns with', servers.length, 'servers'); + // Add server options servers.forEach(server => { + console.log(`🎭 Adding server to dropdown: ${server.guild_name} (guild_id: ${server.guild_id}, type: ${typeof server.guild_id})`); + const option = document.createElement('option'); option.value = server.guild_id; option.textContent = server.guild_name; @@ -1161,6 +1165,12 @@ async function populateServerDropdowns() { customPromptServerSelect.appendChild(option.cloneNode(true)); }); + // Debug: Check what's actually in the manual-server-select dropdown + console.log('🎭 manual-server-select options:'); + Array.from(manualServerSelect.options).forEach((opt, idx) => { + console.log(` [${idx}] value="${opt.value}" text="${opt.textContent}"`); + }); + // Populate autonomous stats dropdown populateAutonomousServerDropdown(); } @@ -1333,12 +1343,13 @@ async function sendFigurineNow() { } async function addServer() { - const guildId = parseInt(document.getElementById('new-guild-id').value); + // Don't use parseInt() for Discord IDs - they're too large for JS integers + const guildId = document.getElementById('new-guild-id').value.trim(); const guildName = document.getElementById('new-guild-name').value; - const autonomousChannelId = parseInt(document.getElementById('new-autonomous-channel-id').value); + const autonomousChannelId = document.getElementById('new-autonomous-channel-id').value.trim(); const autonomousChannelName = document.getElementById('new-autonomous-channel-name').value; const bedtimeChannelIds = document.getElementById('new-bedtime-channel-ids').value - .split(',').map(id => parseInt(id.trim())).filter(id => !isNaN(id)); + .split(',').map(id => id.trim()).filter(id => id.length > 0); const enabledFeatures = []; if (document.getElementById('feature-autonomous').checked) enabledFeatures.push('autonomous'); @@ -1659,7 +1670,8 @@ async function triggerAutonomous(actionType) { // Add guild_id as query parameter if a specific server is selected if (selectedServer !== 'all') { - endpoint += `?guild_id=${parseInt(selectedServer)}`; + // Don't use parseInt() - Discord IDs are too large for JS integers + endpoint += `?guild_id=${selectedServer}`; } const response = await fetch(endpoint, { @@ -1968,7 +1980,8 @@ async function sendCustomPrompt() { // Add guild_id as query parameter if a specific server is selected if (selectedServer !== 'all') { - endpoint += `?guild_id=${parseInt(selectedServer)}`; + // Don't use parseInt() - Discord IDs are too large for JS integers + endpoint += `?guild_id=${selectedServer}`; } requestData = { prompt: prompt }; @@ -2024,14 +2037,24 @@ async function wakeUp() { async function sendBedtime() { const selectedServer = document.getElementById('manual-server-select').value; + // Debug logging + console.log('🛏️ sendBedtime() called'); + console.log('🛏️ Selected server value:', selectedServer); + console.log('🛏️ Selected server type:', typeof selectedServer); + try { let endpoint = '/bedtime'; // Add guild_id as query parameter if a specific server is selected if (selectedServer !== 'all') { - endpoint += `?guild_id=${parseInt(selectedServer)}`; + // IMPORTANT: Don't use parseInt() - it causes precision loss! + // Keep as string since Discord IDs are too large for JS integers + console.log('🛏️ Using guild_id (as string):', selectedServer); + endpoint += `?guild_id=${selectedServer}`; } + console.log('🛏️ Final endpoint:', endpoint); + const response = await fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }