fix: add audio manager fallback and debug logging for radio voice connection
This commit is contained in:
parent
77649ff6ca
commit
fdc9df2946
1 changed files with 40 additions and 5 deletions
|
|
@ -68,7 +68,10 @@ public class RadioManager {
|
||||||
var finalState = radioStates.computeIfAbsent(guildId, id -> new GuildRadioState());
|
var finalState = radioStates.computeIfAbsent(guildId, id -> new GuildRadioState());
|
||||||
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) {
|
||||||
|
logger.warn("Radio: guild {} not found in radio bot cache", guildId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
var client = lavalinkManager.getClient();
|
var client = lavalinkManager.getClient();
|
||||||
if (client != null
|
if (client != null
|
||||||
&& !VoiceHelper.waitForCondition(
|
&& !VoiceHelper.waitForCondition(
|
||||||
|
|
@ -79,11 +82,43 @@ public class RadioManager {
|
||||||
logger, "Radio: Lavalink node not ready for guild " + guildId);
|
logger, "Radio: Lavalink node not ready for guild " + guildId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
guild.getJDA().getDirectAudioController().connect(guild.getVoiceChannelById(channelId));
|
var vc = guild.getVoiceChannelById(channelId);
|
||||||
|
if (vc == null) {
|
||||||
|
logger.warn("Radio: voice channel {} not found in guild {}", channelId, guildId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logger.debug("Radio: connecting to channel {}/{} in guild {}", vc.getName(), channelId, guildId);
|
||||||
|
guild.getJDA().getDirectAudioController().connect(vc);
|
||||||
|
if (!guild.getAudioManager().isConnected()) {
|
||||||
|
guild.getAudioManager().openAudioConnection(vc);
|
||||||
|
}
|
||||||
var self = guild.getMember(guild.getJDA().getSelfUser());
|
var self = guild.getMember(guild.getJDA().getSelfUser());
|
||||||
if (!VoiceHelper.waitForCondition(
|
if (self == null) {
|
||||||
() -> self.getVoiceState().inAudioChannel(), VOICE_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
|
logger.warn("Radio: self member is null for guild {}", guildId);
|
||||||
LoggerDecorator.warn(logger, "Radio: voice connection timeout for guild " + guildId);
|
return;
|
||||||
|
}
|
||||||
|
logger.debug(
|
||||||
|
"Radio: initial voice state for guild {}: inAudioChannel={}",
|
||||||
|
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(
|
||||||
|
"Radio: voice connection timeout for guild {} (channel: {})",
|
||||||
|
guildId,
|
||||||
|
self.getVoiceState().getChannel() != null
|
||||||
|
? self.getVoiceState().getChannel().getId()
|
||||||
|
: "null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var link = lavalinkManager.getOrCreateLink(guildId);
|
var link = lavalinkManager.getOrCreateLink(guildId);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue