use of org.jmusixmatch.MusixMatchException in project Rubicon by Rubicon-Bot.
the class MusicManager method executeLyrics.
public Message executeLyrics() {
if (!isBotInVoiceChannel())
return message(error("Error!", "Bot is not in a voice channel."));
VoiceChannel channel = getBotsVoiceChannel();
if (parsedCommandInvocation.getMember().getVoiceState().getChannel() != channel)
return message(error("Error!", "You have to be in the same voice channel as the bot."));
if (getCurrentMusicManager().getPlayer().getPlayingTrack() == null) {
return message(error("Error!", "Bot is playing nothing."));
}
MusixMatch musixMatch = new MusixMatch(Info.MUSIXMATCH_KEY);
AudioTrackInfo info = this.getCurrentTrack().getInfo();
Track track;
Lyrics lyrics;
try {
track = musixMatch.getMatchingTrack(info.title, info.author);
lyrics = musixMatch.getLyrics(track.getTrack().getTrackId());
} catch (MusixMatchException e) {
return new MessageBuilder().setEmbed(EmbedUtil.error("No lyrics found", "There are no lyrics of the current song on Musixmatch").build()).build();
}
EmbedBuilder lyricsEmbed = new EmbedBuilder();
lyricsEmbed.setColor(Colors.COLOR_PREMIUM);
lyricsEmbed.setTitle("Lyrics of `" + track.getTrack().getTrackName() + "`", track.getTrack().getTrackShareUrl());
lyricsEmbed.setFooter(lyrics.getLyricsCopyright(), null);
lyricsEmbed.setDescription(lyrics.getLyricsBody());
return new MessageBuilder().setEmbed(lyricsEmbed.build()).build();
}
Aggregations