use of com.discordbolt.api.command.exceptions.CommandStateException 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());
}
use of com.discordbolt.api.command.exceptions.CommandStateException in project BoltBot by DiscordBolt.
the class Playlist method addSong.
public String addSong(IUser requester, String songID) throws CommandStateException, CommandPermissionException {
if (!(ownerID.equals(requester.getLongID()) || contributors.contains(requester.getLongID())))
throw new CommandPermissionException("You are not allowed to add songs to " + this.getTitle() + ".");
if (songs.containsKey(songID))
throw new CommandStateException("That song is already in this playlist!");
String songTitle = MusicModule.getVoiceManager().getSongTitle(songID);
songs.put(songID, songTitle);
PlaylistManager.writePlaylistFile(this);
return songTitle;
}
use of com.discordbolt.api.command.exceptions.CommandStateException in project BoltBot by DiscordBolt.
the class Playlist method addContributor.
public void addContributor(IUser requestor, IUser contributor) throws CommandStateException, CommandPermissionException {
if (!ownerID.equals(requestor.getLongID()))
throw new CommandPermissionException("You are not allowed to add contributors to " + this.getTitle() + ".");
if (contributors.contains(contributor.getLongID()))
throw new CommandStateException(contributor.getName() + " is already a contributor to " + this.getTitle() + ".");
contributors.add(contributor.getLongID());
PlaylistManager.writePlaylistFile(this);
}
use of com.discordbolt.api.command.exceptions.CommandStateException in project BoltBot by DiscordBolt.
the class PlaylistManager method createPlaylist.
public Playlist createPlaylist(String title, IUser owner, IGuild guild) throws CommandStateException {
if (playlists.stream().filter(p -> p.getTitle().equalsIgnoreCase(title)).findAny().isPresent())
throw new CommandStateException("There already exists a playlist with that title!");
Playlist pl = new Playlist(title, owner, guild);
// Saves the playlist to disk
writePlaylistFile(pl);
playlists.add(pl);
Collections.sort(playlists);
return pl;
}
use of com.discordbolt.api.command.exceptions.CommandStateException in project BoltBot by DiscordBolt.
the class DJ method removeStar.
public void removeStar(IMessage message, IUser user) throws CommandStateException, CommandPermissionException {
if (message == null || user == null || !trackMessages.containsKey(message))
throw new CommandStateException("That track can not be found.");
AudioTrack track = trackMessages.get(message);
Playlist playlist = MusicModule.getPlaylistManager().getSelectedPlaylist(user.getLongID());
if (playlist == null)
throw new CommandStateException("You must have a selected playlist to unsave a song!");
playlist.removeSong(user, track);
}
Aggregations