use of com.discordbolt.boltbot.modules.music.playlists.Playlist in project BoltBot by DiscordBolt.
the class PlaylistCommand method playlistListCommand.
@BotCommand(command = { "playlist", "list" }, module = MusicModule.MODULE, aliases = "pl", allowPM = true, description = "List all stored playlists", usage = "Playlist list", allowedChannels = "music", args = 2)
public static void playlistListCommand(CommandContext cc) throws CommandException {
EmbedBuilder embed = new EmbedBuilder();
embed.withColor(MusicModule.EMBED_COLOR);
embed.withAuthorName("Playlists");
List<Playlist> playlists = MusicModule.getPlaylistManager().getPlaylists();
embed.withTitle("Number of Playlists:");
embed.withDescription(playlists.size() + "");
IUser currentUser = null;
StringBuilder sb = new StringBuilder();
int id = 1;
for (Playlist pl : playlists) {
if (currentUser == null || !pl.getOwnerID().equals(currentUser.getLongID())) {
if (currentUser != null)
embed.appendField(currentUser.getName(), sb.toString(), false);
sb.setLength(0);
currentUser = pl.getOwner();
}
if (sb.length() != 0)
sb.append('\n');
sb.append(id++).append(". ").append(pl.getTitle());
}
if (currentUser != null)
embed.appendField(currentUser.getName(), sb.toString(), false);
cc.replyWith(embed.build());
}
use of com.discordbolt.boltbot.modules.music.playlists.Playlist in project BoltBot by DiscordBolt.
the class PlaylistCommand method playlistSelectCommand.
@BotCommand(command = { "playlist", "select" }, module = MusicModule.MODULE, aliases = "pl", allowPM = true, description = "Select a playlist", usage = "Playlist select [number/name]", allowedChannels = "music", minArgs = 3, maxArgs = 100)
public static void playlistSelectCommand(CommandContext cc) throws CommandException {
if (cc.getArgCount() == 3 && cc.getArgument(2).matches("^-?\\d+$")) {
int playlistIndex = Integer.valueOf(cc.getArgument(2)) - 1;
Playlist playlist = MusicModule.getPlaylistManager().getPlaylist(playlistIndex);
MusicModule.getPlaylistManager().setSelectedPlaylist(cc.getAuthor().getLongID(), playlist);
cc.replyWith("Successfully selected " + playlist.getTitle() + " by " + playlist.getOwner().getName() + " as your selected playlist.");
} else {
Optional<Playlist> playlist = MusicModule.getPlaylistManager().getPlaylist(getPlaylistName(cc));
if (!playlist.isPresent())
throw new CommandArgumentException(NO_SUCH_PLAYLIST);
MusicModule.getPlaylistManager().setSelectedPlaylist(cc.getAuthor().getLongID(), playlist.get());
cc.replyWith("Successfully selected " + playlist.get().getTitle() + " by " + playlist.get().getOwner().getName() + " as your selected playlist.");
}
}
use of com.discordbolt.boltbot.modules.music.playlists.Playlist in project BoltBot by DiscordBolt.
the class PlaylistCommand method playlistAddCommand.
@BotCommand(command = { "playlist", "add" }, module = MusicModule.MODULE, aliases = "pl", allowPM = true, description = "Add a song to your selected playlist", usage = "Playlist add [URL]", allowedChannels = "music", args = 3)
public static void playlistAddCommand(CommandContext cc) throws CommandException {
Playlist selectedPlaylist = MusicModule.getPlaylistManager().getSelectedPlaylist(cc.getAuthor().getLongID());
if (selectedPlaylist == null)
throw new CommandStateException(NO_PLAYLIST_SELECTED);
String title = selectedPlaylist.addSong(cc.getAuthor(), cc.getArgument(2));
cc.replyWith("Added \"" + title + "\" to " + selectedPlaylist.getTitle());
}
use of com.discordbolt.boltbot.modules.music.playlists.Playlist in project BoltBot by DiscordBolt.
the class PlaylistCommand method playlistCreateCommand.
@BotCommand(command = { "playlist", "create" }, module = MusicModule.MODULE, aliases = "pl", description = "Create a new playlist", usage = "Playlist create [name]", allowedChannels = "music", minArgs = 3, maxArgs = 100)
public static void playlistCreateCommand(CommandContext cc) throws CommandException {
String title = getPlaylistName(cc);
if (title.length() > 250)
throw new CommandArgumentException("Playlist titles can only be 250 characters long.");
if (!title.matches("[a-zA-Z0-9 ]+"))
throw new CommandArgumentException("Playlist titles can only contain alphanumeric characters and spaces.");
Playlist playlist = MusicModule.getPlaylistManager().createPlaylist(title, cc.getAuthor(), cc.getGuild());
MusicModule.getPlaylistManager().setSelectedPlaylist(cc.getAuthor().getLongID(), playlist);
cc.replyWith("Successfully created playlist: " + playlist.getTitle());
}
use of com.discordbolt.boltbot.modules.music.playlists.Playlist in project BoltBot by DiscordBolt.
the class PlaylistCommand method playlistUnshareCommand.
@BotCommand(command = { "playlist", "unshare" }, module = MusicModule.MODULE, aliases = "pl", allowPM = true, description = "Remove another user's access to add/remove songs", usage = "Playlist unshare [@User]", allowedChannels = "music", args = 3)
public static void playlistUnshareCommand(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.removeContributor(cc.getAuthor(), cc.getMessage().getMentions().get(0));
cc.replyWith("Successfully removed " + cc.getMessage().getMentions().get(0).getName() + " from being a contributor to playlist " + selectedPlaylist.getTitle());
}
Aggregations