Search in sources :

Example 1 with CommandPermissionException

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);
}
Also used : CommandPermissionException(com.discordbolt.api.command.exceptions.CommandPermissionException) CommandStateException(com.discordbolt.api.command.exceptions.CommandStateException)

Example 2 with CommandPermissionException

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);
}
Also used : CommandPermissionException(com.discordbolt.api.command.exceptions.CommandPermissionException) CommandStateException(com.discordbolt.api.command.exceptions.CommandStateException)

Example 3 with CommandPermissionException

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);
}
Also used : CommandPermissionException(com.discordbolt.api.command.exceptions.CommandPermissionException) CommandStateException(com.discordbolt.api.command.exceptions.CommandStateException)

Example 4 with CommandPermissionException

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.");
}
Also used : CommandPermissionException(com.discordbolt.api.command.exceptions.CommandPermissionException) TagData(com.discordbolt.boltbot.system.mysql.data.persistent.TagData) CommandStateException(com.discordbolt.api.command.exceptions.CommandStateException) BotCommand(com.discordbolt.api.command.BotCommand)

Example 5 with CommandPermissionException

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;
}
Also used : CommandPermissionException(com.discordbolt.api.command.exceptions.CommandPermissionException) CommandStateException(com.discordbolt.api.command.exceptions.CommandStateException)

Aggregations

CommandPermissionException (com.discordbolt.api.command.exceptions.CommandPermissionException)6 CommandStateException (com.discordbolt.api.command.exceptions.CommandStateException)6 BotCommand (com.discordbolt.api.command.BotCommand)1 TagData (com.discordbolt.boltbot.system.mysql.data.persistent.TagData)1