From 9b675bfed452ef0237f5663563e6b107fa319c30 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sat, 28 Dec 2024 13:54:31 +0700 Subject: [PATCH] fix: NullPointerException when `*music loop current` is run without song playing --- .../chayapak1/chomens_bot/commands/MusicCommand.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java index dc675458..3b190b0a 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java @@ -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;