use of com.discordbolt.api.command.exceptions.CommandPermissionException in project BoltBot by DiscordBolt.
the class Playlist method removeSong.
public void removeSong(IUser requester, AudioTrack track) throws CommandStateException, CommandPermissionException {
if (!(ownerID.equals(requester.getLongID()) || contributors.contains(requester.getLongID())))
throw new CommandPermissionException("You are not allowed to remove songs from " + this.getTitle() + ".");
if (!songs.containsValue(track.getInfo().title))
throw new CommandStateException("That song is not in this playlist!");
songs.values().remove(track.getInfo().title);
PlaylistManager.writePlaylistFile(this);
}
use of com.discordbolt.api.command.exceptions.CommandPermissionException in project BoltBot by DiscordBolt.
the class Playlist method removeSong.
public void removeSong(IUser requester, String songID) throws CommandStateException, CommandPermissionException {
if (!(ownerID.equals(requester.getLongID()) || contributors.contains(requester.getLongID())))
throw new CommandPermissionException("You are not allowed to remove songs from " + this.getTitle() + ".");
if (!songs.containsKey(songID))
throw new CommandStateException("That song is not in this playlist!");
songs.remove(songID);
PlaylistManager.writePlaylistFile(this);
}
use of com.discordbolt.api.command.exceptions.CommandPermissionException in project BoltBot by DiscordBolt.
the class Playlist method removeSong.
public void removeSong(IUser requester, int index) throws CommandPermissionException, CommandStateException {
if (!(ownerID.equals(requester.getLongID()) || contributors.contains(requester.getLongID())))
throw new CommandPermissionException("You are not allowed to remove songs from " + this.getTitle() + ".");
if (index < 0 || index >= songs.size())
throw new CommandStateException(index + " is not a valid index!");
songs.remove(getSongIDs().get(index));
PlaylistManager.writePlaylistFile(this);
}
use of com.discordbolt.api.command.exceptions.CommandPermissionException in project BoltBot by DiscordBolt.
the class TagModule method tagEditCommand.
@BotCommand(command = { "tag", "edit" }, description = "Edits a Tag", usage = "Tag edit [tag]", module = "Tag Module", minArgs = 4, maxArgs = 100)
public static void tagEditCommand(CommandContext cc) throws CommandException {
Optional<TagData> tag = TagData.getById(cc.getGuild().getLongID(), cc.getArgument(2));
if (!tag.isPresent())
throw new CommandStateException("That tag does not exist!");
if (tag.get().getUserId() != cc.getAuthor().getLongID())
throw new CommandPermissionException("You do not have permission to edit this tag!");
tag.get().setContent(cc.combineArgs(3, cc.getArgCount() - 1));
cc.replyWith("Successfully updated your tag. Use `" + getTagPrefix(cc.getGuild()) + tag.get().getName() + "` to view it.");
}
use of com.discordbolt.api.command.exceptions.CommandPermissionException 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;
}
Aggregations