lyrics second pass
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user