Skip to content

Commit 95de05f

Browse files
authored
Merge pull request #940 from MichailiK/feature/use-lyrics-anytime
Allow usage of LyricsCmd without playing music
2 parents b83028f + e242fa9 commit 95de05f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,29 @@ public LyricsCmd(Bot bot)
3636
super(bot);
3737
this.name = "lyrics";
3838
this.arguments = "[song name]";
39-
this.help = "shows the lyrics to the currently-playing song";
39+
this.help = "shows the lyrics of a song";
4040
this.aliases = bot.getConfig().getAliases(this.name);
4141
this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS};
42-
this.bePlaying = true;
4342
}
4443

4544
@Override
4645
public void doCommand(CommandEvent event)
4746
{
48-
event.getChannel().sendTyping().queue();
4947
String title;
5048
if(event.getArgs().isEmpty())
51-
title = ((AudioHandler)event.getGuild().getAudioManager().getSendingHandler()).getPlayer().getPlayingTrack().getInfo().title;
49+
{
50+
AudioHandler sendingHandler = (AudioHandler) event.getGuild().getAudioManager().getSendingHandler();
51+
if (sendingHandler.isMusicPlaying(event.getJDA()))
52+
title = sendingHandler.getPlayer().getPlayingTrack().getInfo().title;
53+
else
54+
{
55+
event.replyError("There must be music playing to use that!");
56+
return;
57+
}
58+
}
5259
else
5360
title = event.getArgs();
61+
event.getChannel().sendTyping().queue();
5462
client.getLyrics(title).thenAccept(lyrics ->
5563
{
5664
if(lyrics == null)

0 commit comments

Comments
 (0)