From 247cb549ba9ff330437d294f7186294a28aea513 Mon Sep 17 00:00:00 2001 From: ErdbeerbaerLP Date: Thu, 11 Jul 2024 21:47:52 +0200 Subject: [PATCH] Fix shuffle parameter of play command --- .../jmusicbot/commands/music/PlayCmd.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java index f5e15c323..08cd4c9e3 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java @@ -18,6 +18,7 @@ import com.github.topi314.lavasrc.spotify.SpotifySourceManager; import com.jagrosh.jmusicbot.audio.RequestMetadata; import com.jagrosh.jmusicbot.audio.SponsorblockHandler; +import com.jagrosh.jmusicbot.commands.owner.PlaylistCmd; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.TimeUtil; import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; @@ -77,26 +78,24 @@ public PlayCmd(Bot bot) @Override public void doCommand(CommandEvent event) { - // Spotify Workaround - final Matcher spotifyMatcher = SpotifySourceManager.URL_PATTERN.matcher(event.getArgs()); - System.out.println(event.getArgs()); - if(spotifyMatcher.matches()){ - try{ + try { + // Spotify Workaround + final Matcher spotifyMatcher = SpotifySourceManager.URL_PATTERN.matcher(event.getArgs()); + if (spotifyMatcher.find()) { final Field argField = event.getClass().getDeclaredField("args"); argField.setAccessible(true); final String arg = (String) argField.get(event); final String region = spotifyMatcher.group("region"); - if(region == null || region.isEmpty()){ + if (region == null || region.isEmpty()) { argField.set(event, arg.replace("spotify.com/", "spotify.com/intl/")); - }else if(!region.equals("intl")) argField.set(event, arg.replace(region, "intl")); - }catch (Exception ignored){ - ignored.printStackTrace(); + } else if (!region.equals("intl")) argField.set(event, arg.replace(region, "intl")); } + + } catch (Exception ignored) { } - System.out.println(event.getArgs()); String argsIn = event.getArgs(); boolean shuffle = argsIn.endsWith(" ?shuffle"); - if(shuffle) argsIn = argsIn.replace(" ?shuffle",""); + if (shuffle) argsIn = argsIn.replace(" ?shuffle", ""); if(argsIn.isEmpty() && event.getMessage().getAttachments().isEmpty()) { AudioHandler handler = (AudioHandler)event.getGuild().getAudioManager().getSendingHandler();