diff --git a/src/main/java/handiebot/command/commands/music/PlayNowCommand.java b/src/main/java/handiebot/command/commands/music/PlayNowCommand.java new file mode 100644 index 0000000..a0bf26d --- /dev/null +++ b/src/main/java/handiebot/command/commands/music/PlayNowCommand.java @@ -0,0 +1,79 @@ +package handiebot.command.commands.music; + +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.types.ContextCommand; +import handiebot.lavaplayer.TrackScheduler; +import handiebot.lavaplayer.playlist.UnloadedTrack; +import handiebot.utils.MessageUtils; +import handiebot.utils.YoutubeSearch; +import sx.blah.discord.handle.obj.IMessage; + +import java.util.ArrayList; +import java.util.List; + +import static handiebot.HandieBot.resourceBundle; +import static handiebot.utils.MessageUtils.sendMessage; +import static handiebot.utils.YoutubeSearch.WATCH_URL; + +/** + * @author Andrew Lalis + * Command to make a song play immediately. + */ +public class PlayNowCommand extends ContextCommand { +//TODO: Externalize strings. + public PlayNowCommand() { + super("playnow", + "", + resourceBundle.getString("commands.command.playnow.description"), + 8); + } + + @Override + public void execute(CommandContext context) { + if (context.getArgs().length < 1){ + sendMessage("You must provide a URL or series of words to search.", context.getChannel()); + } + if (context.getArgs()[0].startsWith("http")) { + //The user has given only a URL. + try { + playTrackNow(new UnloadedTrack(context.getArgs()[0]), context); + } catch (Exception e) { + e.printStackTrace(); + sendMessage("Unable to load the song.", context.getChannel()); + } + } else { + //The user has given a search query. + List