Fix: Separate voice groups so radio + soundboard play in parallel

Each plugin now uses its own @discordjs/voice group:
- Radio: group='radio'
- Soundboard: group='soundboard'

This prevents joinVoiceChannel from one bot overwriting the
other bot's connection. Both bots can now play simultaneously
in the same voice channel. Removed claimVoice system (not needed
with separate bots).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel 2026-03-06 11:07:31 +01:00
parent 3cd9f6f169
commit b9a9347356
2 changed files with 12 additions and 19 deletions

View file

@ -7,7 +7,6 @@ import {
import type { VoiceBasedChannel } from 'discord.js';
import { ChannelType } from 'discord.js';
import type { Plugin, PluginContext } from '../../core/plugin.js';
import { claimVoice, releaseVoice } from '../../core/plugin.js';
import { sseBroadcast } from '../../core/sse.js';
import { getState, setState } from '../../core/persistence.js';
import {
@ -67,9 +66,8 @@ function stopStream(guildId: string): void {
if (!state) return;
try { state.ffmpeg.kill('SIGKILL'); } catch {}
try { state.player.stop(true); } catch {}
try { getVoiceConnection(guildId)?.destroy(); } catch {}
try { getVoiceConnection(guildId, 'radio')?.destroy(); } catch {}
guildRadioState.delete(guildId);
releaseVoice(guildId, 'radio');
broadcastState(guildId);
console.log(`[Radio] Stopped stream in guild ${guildId}`);
}
@ -97,6 +95,7 @@ async function startStream(
guildId,
adapterCreator: guild.voiceAdapterCreator,
selfDeaf: true,
group: 'radio',
});
try {
@ -128,7 +127,7 @@ async function startStream(
if (guildRadioState.has(guildId)) {
console.log(`[Radio] ffmpeg exited (code ${code}), cleaning up`);
guildRadioState.delete(guildId);
try { connection.destroy(); } catch {}
try { getVoiceConnection(guildId, 'radio')?.destroy(); } catch {}
broadcastState(guildId);
}
});
@ -150,9 +149,6 @@ async function startStream(
stopStream(guildId);
});
// Claim voice for this guild (stops other plugins like soundboard)
claimVoice(guildId, 'radio', () => stopStream(guildId));
// State tracken
const channelName = 'name' in channel ? (channel as any).name : voiceChannelId;
guildRadioState.set(guildId, {