use of com.discordbolt.boltbot.modules.music.playlists.Playlist in project BoltBot by DiscordBolt.
the class PlayCommand method playPlaylist.
@BotCommand(command = { "play", "-p" }, module = MusicModule.MODULE, description = "Queue up the requested playlist", usage = "Play playlist {number/name}", allowedChannels = "music", minArgs = 2, maxArgs = 100)
public static void playPlaylist(CommandContext cc) throws CommandException {
if (cc.getArgCount() == 2) {
Playlist current = MusicModule.getPlaylistManager().getSelectedPlaylist(cc.getAuthor().getLongID());
if (current == null)
throw new CommandStateException("You do not have a selected playlist to queue!");
MusicModule.getVoiceManager().queue(cc.getGuild(), cc.getAuthor(), current);
cc.replyWith("Your playlist is now being queued and may take ~30 seconds to fully appear in the queue.");
} else {
String playlistRequest = cc.combineArgs(2, cc.getArgCount() - 1);
if (playlistRequest.contains(":")) {
String playlistTitle = playlistRequest.split(":")[0];
String playlistNumber = playlistRequest.split(":")[1];
int songNumber;
try {
songNumber = Integer.valueOf(playlistNumber);
} catch (NumberFormatException e) {
throw new CommandArgumentException("\"" + playlistRequest.split(":")[1] + "\" is not a valid number!");
}
Playlist toPlay = MusicModule.getPlaylistManager().getPlaylist(playlistTitle).orElse(null);
if (toPlay == null)
throw new CommandArgumentException("\"" + playlistTitle + "\" could not be found!");
if (songNumber < 1 || songNumber > toPlay.getSongIDs().size())
throw new CommandArgumentException("\"" + songNumber + "\" is not a valid number for \"" + toPlay.getTitle() + "\"");
MusicModule.getVoiceManager().queue(cc.getGuild(), cc.getAuthor(), toPlay.getSongIDs().get(songNumber - 1));
} else {
Playlist toPlay = MusicModule.getPlaylistManager().getPlaylist(playlistRequest).orElse(null);
if (toPlay == null)
throw new CommandArgumentException("\"" + playlistRequest + "\" could not be found!");
MusicModule.getVoiceManager().queue(cc.getGuild(), cc.getAuthor(), toPlay);
cc.replyWith("Your playlist is now being queued and may take ~30 seconds to fully appear in the queue.");
}
}
}
use of com.discordbolt.boltbot.modules.music.playlists.Playlist in project BoltBot by DiscordBolt.
the class PlaylistCommand method playlistRemoveCommand.
@BotCommand(command = { "playlist", "remove" }, module = MusicModule.MODULE, aliases = "pl", allowPM = true, description = "Remove a song from your selected playlist", usage = "Playlist remove [number/URL]", allowedChannels = "music", args = 3)
public static void playlistRemoveCommand(CommandContext cc) throws CommandException {
Playlist selectedPlaylist = MusicModule.getPlaylistManager().getSelectedPlaylist(cc.getAuthor().getLongID());
if (selectedPlaylist == null)
throw new CommandStateException(NO_PLAYLIST_SELECTED);
if (cc.getArgument(2).matches("^-?\\d+$")) {
selectedPlaylist.removeSong(cc.getAuthor(), Integer.valueOf(cc.getArgument(2)) - 1);
} else {
selectedPlaylist.removeSong(cc.getAuthor(), cc.getArgument(2));
}
cc.replyWith("Successfully removed the song from " + selectedPlaylist.getTitle() + ".");
}
use of com.discordbolt.boltbot.modules.music.playlists.Playlist in project BoltBot by DiscordBolt.
the class PlaylistCommand method playlistViewCommand.
@BotCommand(command = { "playlist", "view" }, module = MusicModule.MODULE, aliases = "pl", allowPM = true, description = "View a playlist's details", usage = "Playlist view {name}", allowedChannels = "music", minArgs = 2, maxArgs = 100)
public static void playlistViewCommand(CommandContext cc) throws CommandException {
if (cc.getArgCount() == 2) {
Playlist playlist = MusicModule.getPlaylistManager().getSelectedPlaylist(cc.getAuthor().getLongID());
if (playlist == null)
throw new CommandStateException(NO_PLAYLIST_SELECTED);
cc.replyWith(playlist.toEmbed());
} else {
Optional<Playlist> playlist = MusicModule.getPlaylistManager().getPlaylist(getPlaylistName(cc));
if (!playlist.isPresent())
throw new CommandArgumentException(NO_SUCH_PLAYLIST);
cc.replyWith(playlist.get().toEmbed());
}
}
use of com.discordbolt.boltbot.modules.music.playlists.Playlist in project BoltBot by DiscordBolt.
the class PlaylistCommand method playlistShareCommand.
@BotCommand(command = { "playlist", "share" }, module = MusicModule.MODULE, aliases = "pl", allowPM = true, description = "Give another user access to add/remove songs", usage = "Playlist share [@User]", allowedChannels = "music", args = 3)
public static void playlistShareCommand(CommandContext cc) throws CommandException {
Playlist selectedPlaylist = MusicModule.getPlaylistManager().getSelectedPlaylist(cc.getAuthor().getLongID());
if (selectedPlaylist == null)
throw new CommandStateException(NO_PLAYLIST_SELECTED);
if (cc.getMessage().getMentions().size() != 1) {
cc.sendUsage();
return;
}
selectedPlaylist.addContributor(cc.getAuthor(), cc.getMessage().getMentions().get(0));
cc.replyWith("Successfully added " + cc.getMessage().getMentions().get(0).getName() + " as a contributor to playlist " + selectedPlaylist.getTitle());
}
use of com.discordbolt.boltbot.modules.music.playlists.Playlist in project BoltBot by DiscordBolt.
the class DJ method starSong.
public void starSong(AudioTrack track, IUser user) throws CommandStateException, CommandPermissionException {
if (track == null || user == null)
throw new CommandStateException("That track can not be found.");
Playlist playlist = MusicModule.getPlaylistManager().getSelectedPlaylist(user.getLongID());
if (playlist == null)
throw new CommandStateException("You must have a selected playlist to save a song!");
playlist.addSong(user, track.getInfo().uri);
}
Aggregations