debug: add logging to JDAVoiceUpdateListener
This commit is contained in:
parent
bdaba4825c
commit
0918bb5c38
1 changed files with 16 additions and 2 deletions
|
|
@ -8,8 +8,12 @@ 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) {
|
||||
|
|
@ -24,18 +28,28 @@ public class JDAVoiceUpdateListener implements VoiceDispatchInterceptor {
|
|||
Guild guild = update.getGuild();
|
||||
|
||||
Member selfMember = guild.getMember(guild.getJDA().getSelfUser());
|
||||
if (selfMember == null) return;
|
||||
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(guild.getIdLong(), region).onVoiceServerUpdate(state);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue