feat(dashboard): leave voice when server/channel set to 없음

The voice-channel picker already switched channels / left on 없음. Now the
server picker does too: choosing 없음 (or switching to a server with no channel
selected) sends a leave so the bot exits its current voice channel. Factored the
select POST into sendSelect(guildId, channelId).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-08-22 22:15:42 +09:00
parent f1f059a018
commit 7ea07c13ad

View File

@@ -1126,15 +1126,21 @@ function renderBot(s){
? '참여자: '+members.map(m=>'<span class="part'+(m.speaking?' spk':'')+'">'+(m.speaking?'🔊':'👤')+' '+esc(m.name||m.id)+'</span>').join('') ? '참여자: '+members.map(m=>'<span class="part'+(m.speaking?' spk':'')+'">'+(m.speaking?'🔊':'👤')+' '+esc(m.name||m.id)+'</span>').join('')
: (s&&s.connected&&cur.channelId ? '참여자: (없음)' : ''); : (s&&s.connected&&cur.channelId ? '참여자: (없음)' : '');
} }
$('guildSel').onchange = ()=>{ userPickedGuild=$('guildSel').value; renderBot(botState); }; async function sendSelect(guildId, channelId){
$('vcSel').onchange = async ()=>{
const guildId=$('guildSel').value, channelId=$('vcSel').value;
try{ try{
await fetch('/api/bot/select',{method:'POST',headers:{'Content-Type':'application/json'}, await fetch('/api/bot/select',{method:'POST',headers:{'Content-Type':'application/json'},
body:JSON.stringify({guildId, channelId})}); body:JSON.stringify({guildId, channelId})});
toast(channelId?'음성채널 참여 요청을 보냈습니다':'나가기 요청을 보냈습니다'); toast(channelId?'음성채널 참여 요청을 보냈습니다':'음성채널에서 나가기 요청을 보냈습니다');
}catch(e){ toast('요청 실패: '+e); } }catch(e){ toast('요청 실패: '+e); }
}
$('guildSel').onchange = ()=>{
userPickedGuild = $('guildSel').value;
renderBot(botState); // 선택 서버의 음성채널 목록을 다시 채운다
// 서버를 '없음'으로 두거나 다른 서버로 바꿔 음성채널이 선택되지 않은 상태면 나간다.
if(!$('vcSel').value) sendSelect($('guildSel').value, '');
}; };
// 음성채널 변경 → 그 채널로 이동, '없음' → 나가기.
$('vcSel').onchange = ()=> sendSelect($('guildSel').value, $('vcSel').value);
// --- 화이트/블랙리스트 팝업 (유저·역할 검색 → 화이트/블랙 추가·제거) ------ # // --- 화이트/블랙리스트 팝업 (유저·역할 검색 → 화이트/블랙 추가·제거) ------ #
const LKEY = {wu:'whitelistUsers', bu:'blacklistUsers', wr:'whitelistRoles', br:'blacklistRoles'}; const LKEY = {wu:'whitelistUsers', bu:'blacklistUsers', wr:'whitelistRoles', br:'blacklistRoles'};
async function openLists(){ async function openLists(){