From fde75385bd1ce6a11b1b9f7b7bfe85d386d0c486 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Thu, 6 Jul 2017 02:14:34 +0200 Subject: [PATCH] Fixed many things, and now you can use youtube to add to playlists. --- pom.xml | 2 +- src/main/java/handiebot/command/Commands.java | 3 +- .../command/commands/music/PlayCommand.java | 17 +++------ .../commands/music/PlaylistCommand.java | 36 +++++++++++++++---- .../YoutubeChoiceListener.java | 31 ++++++++-------- .../YoutubePlayListener.java | 33 +++++++++++++++++ .../YoutubePlaylistAddListener.java | 29 +++++++++++++++ .../handiebot/lavaplayer/MusicPlayer.java | 5 +-- .../java/handiebot/utils/MessageUtils.java | 22 ++++++++++++ .../java/handiebot/utils/YoutubeSearch.java | 22 ++++++++++++ 10 files changed, 159 insertions(+), 41 deletions(-) create mode 100644 src/main/java/handiebot/command/reactionListeners/YoutubePlayListener.java create mode 100644 src/main/java/handiebot/command/reactionListeners/YoutubePlaylistAddListener.java diff --git a/pom.xml b/pom.xml index 7fd2955..d55581b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.andrewlalis HandieBot - 1.4.0 + 1.4.1 diff --git a/src/main/java/handiebot/command/Commands.java b/src/main/java/handiebot/command/Commands.java index 8fb960a..c3bb520 100644 --- a/src/main/java/handiebot/command/Commands.java +++ b/src/main/java/handiebot/command/Commands.java @@ -52,7 +52,8 @@ public class Commands { public static void executeCommand(String command, CommandContext context){ for (Command cmd : commands) { if (cmd.getName().equals(command)){ - if (cmd instanceof StaticCommand){ + if (cmd instanceof StaticCommand && + ((context != null && cmd.canUserExecute(context.getUser(), context.getGuild())) || context == null)){ log.log(BotLog.TYPE.COMMAND, command+" has been issued."); ((StaticCommand)cmd).execute(); return; diff --git a/src/main/java/handiebot/command/commands/music/PlayCommand.java b/src/main/java/handiebot/command/commands/music/PlayCommand.java index 6a5aa5b..65fd245 100644 --- a/src/main/java/handiebot/command/commands/music/PlayCommand.java +++ b/src/main/java/handiebot/command/commands/music/PlayCommand.java @@ -4,13 +4,11 @@ import com.google.api.services.youtube.model.Video; import handiebot.HandieBot; import handiebot.command.CommandContext; import handiebot.command.ReactionHandler; -import handiebot.command.reactionListeners.YoutubeChoiceListener; +import handiebot.command.reactionListeners.YoutubePlayListener; import handiebot.command.types.ContextCommand; import handiebot.lavaplayer.playlist.UnloadedTrack; import handiebot.utils.YoutubeSearch; -import sx.blah.discord.api.internal.json.objects.EmbedObject; import sx.blah.discord.handle.obj.IMessage; -import sx.blah.discord.util.RequestBuffer; import java.text.MessageFormat; import java.util.ArrayList; @@ -46,24 +44,17 @@ public class PlayCommand extends ContextCommand { e.printStackTrace(); } } else { - //Construct a Youtube song. + //Construct a Youtube song choice. StringBuilder sb = new StringBuilder(); for (int i = 0; i < context.getArgs().length; i++){ sb.append(context.getArgs()[i]).append(' '); } List