Search in sources :

Example 1 with MusixMatchException

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();
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) MusixMatch(org.jmusixmatch.MusixMatch) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo) Lyrics(org.jmusixmatch.entity.lyrics.Lyrics) Track(org.jmusixmatch.entity.track.Track) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) MusixMatchException(org.jmusixmatch.MusixMatchException)

Aggregations

AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)1 AudioTrackInfo (com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)1 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)1 MessageBuilder (net.dv8tion.jda.core.MessageBuilder)1 MusixMatch (org.jmusixmatch.MusixMatch)1 MusixMatchException (org.jmusixmatch.MusixMatchException)1 Lyrics (org.jmusixmatch.entity.lyrics.Lyrics)1 Track (org.jmusixmatch.entity.track.Track)1