fix: wait for Lavalink node readiness before radio voice connection

The radio bot's own LavalinkClient may not be connected yet when
startRadio() is called (async connection). Without this wait, the
voice server update is forwarded to a not-yet-connected client and
lost, causing a voice connection timeout.

Also ensure the radio bot uses its own LavalinkManager (separate
LavalinkClient with radio bot's user ID) instead of sharing the
main bot's, which caused user ID mismatch.
This commit is contained in:
loki5512344 2026-07-12 23:52:26 +02:00
parent cfe05144f9
commit 77649ff6ca
Signed by: boba
GPG key ID: 253067914055423B

View file

@ -69,6 +69,16 @@ public class RadioManager {
finalState.streamUrl = getRadioUrl(guildId); finalState.streamUrl = getRadioUrl(guildId);
Guild guild = radioJda.getGuildById(guildId); Guild guild = radioJda.getGuildById(guildId);
if (guild == null) return; if (guild == null) return;
var client = lavalinkManager.getClient();
if (client != null
&& !VoiceHelper.waitForCondition(
() -> client.getNodes().stream().anyMatch(n -> n.getSessionId() != null),
VOICE_TIMEOUT_MS,
TimeUnit.MILLISECONDS)) {
LoggerDecorator.warn(
logger, "Radio: Lavalink node not ready for guild " + guildId);
return;
}
guild.getJDA().getDirectAudioController().connect(guild.getVoiceChannelById(channelId)); guild.getJDA().getDirectAudioController().connect(guild.getVoiceChannelById(channelId));
var self = guild.getMember(guild.getJDA().getSelfUser()); var self = guild.getMember(guild.getJDA().getSelfUser());
if (!VoiceHelper.waitForCondition( if (!VoiceHelper.waitForCondition(