lyrics second pass

This commit is contained in:
John Grosh
2018-12-05 02:16:39 -05:00
parent ac87cc13d7
commit ae07ac2598
3 changed files with 95 additions and 43 deletions
@@ -45,7 +45,11 @@ public class LyricsCmd extends MusicCommand
@Override
public void doCommand(CommandEvent event)
{
String title = ((AudioHandler)event.getGuild().getAudioManager().getSendingHandler()).getPlayer().getPlayingTrack().getInfo().title;
String title;
if(event.getArgs().isEmpty())
title = ((AudioHandler)event.getGuild().getAudioManager().getSendingHandler()).getPlayer().getPlayingTrack().getInfo().title;
else
title = event.getArgs();
Lyrics lyrics;
try
{
@@ -62,9 +66,33 @@ public class LyricsCmd extends MusicCommand
return;
}
event.reply(new EmbedBuilder().setColor(event.getSelfMember().getColor())
EmbedBuilder eb = new EmbedBuilder()
.setAuthor(lyrics.getAuthor())
.setTitle(lyrics.getTitle(), lyrics.getURL())
.setDescription(lyrics.getContent()).build());
.setColor(event.getSelfMember().getColor())
.setTitle(lyrics.getTitle(), lyrics.getURL());
if(lyrics.getContent().length()>15000)
{
event.replyWarning("Lyrics for `" + title + "` found but likely not correct: " + lyrics.getURL());
}
else if(lyrics.getContent().length()>2000)
{
String content = lyrics.getContent().trim();
while(content.length() > 2000)
{
int index = content.lastIndexOf("\n\n", 2000);
if(index == -1)
index = content.lastIndexOf("\n", 2000);
if(index == -1)
index = content.lastIndexOf(" ", 2000);
if(index == -1)
index = 2000;
event.reply(eb.setDescription(content.substring(0, index).trim()).build());
content = content.substring(index).trim();
eb.setAuthor(null).setTitle(null, null);
}
event.reply(eb.setDescription(content).build());
}
else
event.reply(eb.setDescription(lyrics.getContent()).build());
}
}