fix: JDAVoiceUpdateListener null channel race drops voice server update
The local copy of JDAVoiceUpdateListener.onVoiceServerUpdate() checked if the bot's cached voice channel was null and returned early, silently dropping the voice server update. Discord often sends the voice server update BEFORE the voice state update is processed by JDA, so the channel was always null on first attempt -> Lavalink never received the update -> voice connection never established -> timeout. Fix: pass null channelId to Lavalink's VoiceState instead of aborting. This matches the Kotlin original library code.
This commit is contained in:
parent
fdc9df2946
commit
fa5a6aab8f
2 changed files with 4 additions and 18 deletions
|
|
@ -97,22 +97,8 @@ public class RadioManager {
|
||||||
logger.warn("Radio: self member is null for guild {}", guildId);
|
logger.warn("Radio: self member is null for guild {}", guildId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger.debug(
|
if (!VoiceHelper.waitForCondition(
|
||||||
"Radio: initial voice state for guild {}: inAudioChannel={}",
|
() -> self.getVoiceState().inAudioChannel(), VOICE_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
|
||||||
guildId,
|
|
||||||
self.getVoiceState().inAudioChannel());
|
|
||||||
for (int i = 0; i < 25; i++) {
|
|
||||||
if (self.getVoiceState().inAudioChannel()) break;
|
|
||||||
logger.debug(
|
|
||||||
"Radio: waiting for voice state in guild {} (attempt {})", guildId, i + 1);
|
|
||||||
try {
|
|
||||||
Thread.sleep(200);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!self.getVoiceState().inAudioChannel()) {
|
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"Radio: voice connection timeout for guild {} (channel: {})",
|
"Radio: voice connection timeout for guild {} (channel: {})",
|
||||||
guildId,
|
guildId,
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,9 @@ public class JDAVoiceUpdateListener implements VoiceDispatchInterceptor {
|
||||||
if (selfMember == null) return;
|
if (selfMember == null) return;
|
||||||
|
|
||||||
AudioChannel channel = selfMember.getVoiceState().getChannel();
|
AudioChannel channel = selfMember.getVoiceState().getChannel();
|
||||||
if (channel == null) return;
|
String channelId = channel != null ? String.valueOf(channel.getId()) : null;
|
||||||
|
|
||||||
VoiceState state = new VoiceState(token, endpoint, sessionId, channel.getId());
|
VoiceState state = new VoiceState(token, endpoint, sessionId, channelId);
|
||||||
VoiceRegion region = VoiceRegion.Companion.fromEndpoint(endpoint);
|
VoiceRegion region = VoiceRegion.Companion.fromEndpoint(endpoint);
|
||||||
lavalink.getOrCreateLink(guild.getIdLong(), region).onVoiceServerUpdate(state);
|
lavalink.getOrCreateLink(guild.getIdLong(), region).onVoiceServerUpdate(state);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue