Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle specific track exceptions with a special message
Browse files Browse the repository at this point in the history
MichailiK committed Oct 10, 2024

Verified

This commit was signed with the committer’s verified signature.
MichailiK Michaili K
1 parent 844a1bb commit 96ffcd8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
@@ -53,6 +54,7 @@ public class AudioHandler extends AudioEventAdapter implements AudioSendHandler
public final static String PAUSE_EMOJI = "\u23F8"; // ⏸
public final static String STOP_EMOJI = "\u23F9"; // ⏹

private final static Logger LOGGER = LoggerFactory.getLogger(AudioHandler.class);

private final List<AudioTrack> defaultQueue = new LinkedList<>();
private final Set<String> votes = new HashSet<>();
@@ -202,8 +204,12 @@ public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason
}

@Override
public void onTrackException(AudioPlayer player, AudioTrack track, FriendlyException exception) {
LoggerFactory.getLogger("AudioHandler").error("Track " + track.getIdentifier() + " has failed to play", exception);
public void onTrackException(AudioPlayer player, AudioTrack track, FriendlyException exception)
{
if (exception.getMessage().equals("Sign in to confirm you're not a bot"))
LOGGER.error("Track {} has failed to play: {}. You will need to sign in to Google to play YouTube tracks. More info: https://jmusicbot.com/youtube-oauth2", track.getIdentifier(), exception.getMessage());
else
LOGGER.error("Track {} has failed to play", track.getIdentifier(), exception);
}

@Override

0 comments on commit 96ffcd8

Please sign in to comment.