fix: delete broken local JDAVoiceUpdateListener, use library version with proper voice state handling

This commit is contained in:
loki5512344 2026-07-13 00:17:04 +02:00
parent 0918bb5c38
commit 328845aa75
Signed by: boba
GPG key ID: 253067914055423B
2 changed files with 3 additions and 55 deletions

View file

@ -97,6 +97,9 @@ public class RadioManager {
"Radio: bot has CONNECT permission: {}",
self.hasPermission(vc, net.dv8tion.jda.api.Permission.VOICE_CONNECT));
guild.getJDA().getDirectAudioController().connect(vc);
if (!guild.getAudioManager().isConnected()) {
guild.getAudioManager().openAudioConnection(vc);
}
if (!VoiceHelper.waitForCondition(
() -> self.getVoiceState().inAudioChannel(), VOICE_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
logger.warn(

View file

@ -1,55 +0,0 @@
package dev.arbjerg.lavalink.libraries.jda;
import dev.arbjerg.lavalink.client.LavalinkClient;
import dev.arbjerg.lavalink.client.loadbalancing.VoiceRegion;
import dev.arbjerg.lavalink.protocol.v4.VoiceState;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.hooks.VoiceDispatchInterceptor;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JDAVoiceUpdateListener implements VoiceDispatchInterceptor {
private static final Logger logger =
LoggerFactory.getLogger("JDAVoiceUpdateListener");
private final LavalinkClient lavalink;
public JDAVoiceUpdateListener(LavalinkClient lavalink) {
this.lavalink = lavalink;
}
@Override
public void onVoiceServerUpdate(@NotNull VoiceServerUpdate update) {
String token = update.getToken();
String endpoint = update.getEndpoint();
String sessionId = update.getSessionId();
Guild guild = update.getGuild();
Member selfMember = guild.getMember(guild.getJDA().getSelfUser());
if (selfMember == null) {
logger.warn("onVoiceServerUpdate: selfMember is null for guild {}", update.getGuildIdLong());
return;
}
AudioChannel channel = selfMember.getVoiceState().getChannel();
String channelId = channel != null ? String.valueOf(channel.getId()) : null;
logger.info(
"onVoiceServerUpdate: guild={} endpoint={} channelId={} sessionId={}",
update.getGuildIdLong(), endpoint, channelId, sessionId);
VoiceState state = new VoiceState(token, endpoint, sessionId, channelId);
VoiceRegion region = VoiceRegion.Companion.fromEndpoint(endpoint);
lavalink.getOrCreateLink(update.getGuildIdLong(), region).onVoiceServerUpdate(state);
}
@Override
public boolean onVoiceStateUpdate(@NotNull VoiceStateUpdate update) {
Long channelId = update.getChannel() != null ? update.getChannel().getIdLong() : null;
logger.info(
"onVoiceStateUpdate: guild={} channelId={}",
update.getGuildIdLong(), channelId);
return false;
}
}