From 77649ff6cac5750f122af95147d4f83137e49536 Mon Sep 17 00:00:00 2001 From: loki5512344 Date: Sun, 12 Jul 2026 23:52:26 +0200 Subject: [PATCH] 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. --- .../java/creator/loki/feature/radio/RadioManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/creator/loki/feature/radio/RadioManager.java b/src/main/java/creator/loki/feature/radio/RadioManager.java index 1e9da08..76bdbb6 100644 --- a/src/main/java/creator/loki/feature/radio/RadioManager.java +++ b/src/main/java/creator/loki/feature/radio/RadioManager.java @@ -69,6 +69,16 @@ public class RadioManager { finalState.streamUrl = getRadioUrl(guildId); Guild guild = radioJda.getGuildById(guildId); 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)); var self = guild.getMember(guild.getJDA().getSelfUser()); if (!VoiceHelper.waitForCondition(