use of com.discordbolt.boltbot.system.mysql.data.persistent.TagData 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.boltbot.system.mysql.data.persistent.TagData 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());
}
}
Aggregations