Search in sources :

Example 21 with CommandStateException

use of com.discordbolt.api.command.exceptions.CommandStateException in project BoltBot by DiscordBolt.

the class TagModule method tagAddCommand.

@BotCommand(command = { "tag", "add" }, description = "Adds a Tag", usage = "Tag add [tag]", module = "Tag Module", minArgs = 4, maxArgs = 100)
public static void tagAddCommand(CommandContext cc) throws CommandException {
    try {
        TagData tagData = TagData.create(cc.getGuild().getLongID(), cc.getAuthor().getLongID(), cc.getArgument(2), cc.combineArgs(3, cc.getArgCount() - 1));
        cc.replyWith("Successfully registered your new tag. Use `" + getTagPrefix(cc.getGuild()) + tagData.getName() + "` to view it.");
    } catch (IllegalStateException e) {
        throw new CommandStateException("That tag already exists! Please choose a different tag");
    } catch (IllegalArgumentException e) {
        throw new CommandArgumentException(e.getMessage());
    }
}
Also used : TagData(com.discordbolt.boltbot.system.mysql.data.persistent.TagData) CommandStateException(com.discordbolt.api.command.exceptions.CommandStateException) CommandArgumentException(com.discordbolt.api.command.exceptions.CommandArgumentException) BotCommand(com.discordbolt.api.command.BotCommand)

Aggregations

CommandStateException (com.discordbolt.api.command.exceptions.CommandStateException)21 BotCommand (com.discordbolt.api.command.BotCommand)12 Playlist (com.discordbolt.boltbot.modules.music.playlists.Playlist)8 CommandPermissionException (com.discordbolt.api.command.exceptions.CommandPermissionException)6 CommandArgumentException (com.discordbolt.api.command.exceptions.CommandArgumentException)5 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)3 TagData (com.discordbolt.boltbot.system.mysql.data.persistent.TagData)2 CommandContext (com.discordbolt.api.command.CommandContext)1 CommandException (com.discordbolt.api.command.exceptions.CommandException)1 MusicModule (com.discordbolt.boltbot.modules.music.MusicModule)1 TimeUtil (com.discordbolt.boltbot.utils.TimeUtil)1 List (java.util.List)1 IMessage (sx.blah.discord.handle.obj.IMessage)1 IUser (sx.blah.discord.handle.obj.IUser)1 IVoiceChannel (sx.blah.discord.handle.obj.IVoiceChannel)1 EmbedBuilder (sx.blah.discord.util.EmbedBuilder)1