fix: NullPointerException when *music loop current is run without song playing

This commit is contained in:
ChomeNS
2024-12-28 13:54:31 +07:00
parent 4ace6afccc
commit 9b675bfed4

View File

@@ -244,10 +244,16 @@ public class MusicCommand extends Command {
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
}
case CURRENT -> {
return Component.empty()
if (bot.music.currentSong != null) {
return Component.empty()
.append(Component.text("Now looping "))
.append(Component.text(bot.music.currentSong.name).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)))
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} else {
return Component.empty()
.append(Component.text("Will now loop the next song"))
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
}
}
case ALL -> {
return Component.text("Now looping every song").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
@@ -443,7 +449,7 @@ public class MusicCommand extends Command {
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
}
public Component amplify(CommandContext context) throws CommandException {
public Component amplify (CommandContext context) throws CommandException {
context.checkOverloadArgs(2);
final Bot bot = context.bot;