Search in sources :

Example 1 with GuildPropertyContribution

use of net.robinfriedli.aiode.entities.xml.GuildPropertyContribution in project aiode by robinfriedli.

the class PropertyCommand method describeProperty.

private void describeProperty() {
    GuildPropertyManager guildPropertyManager = Aiode.get().getGuildPropertyManager();
    String propertyName = getCommandInput();
    AbstractGuildProperty property = guildPropertyManager.getPropertyByName(propertyName);
    if (property != null) {
        GuildPropertyContribution contribution = property.getContribution();
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setTitle("Property " + contribution.getName());
        embedBuilder.setDescription(contribution.getDescription());
        long acceptedValuesCount = contribution.query(tagName("acceptedValue")).count();
        if (acceptedValuesCount > 0) {
            embedBuilder.addField("Accepted values", contribution.getAcceptedValuesString(), false);
        }
        sendMessage(embedBuilder);
    } else {
        throw new InvalidCommandException(String.format("No such property '%s'", propertyName));
    }
}
Also used : AbstractGuildProperty(net.robinfriedli.aiode.discord.property.AbstractGuildProperty) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) InvalidCommandException(net.robinfriedli.aiode.exceptions.InvalidCommandException) GuildPropertyContribution(net.robinfriedli.aiode.entities.xml.GuildPropertyContribution) GuildPropertyManager(net.robinfriedli.aiode.discord.property.GuildPropertyManager)

Aggregations

EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)1 AbstractGuildProperty (net.robinfriedli.aiode.discord.property.AbstractGuildProperty)1 GuildPropertyManager (net.robinfriedli.aiode.discord.property.GuildPropertyManager)1 GuildPropertyContribution (net.robinfriedli.aiode.entities.xml.GuildPropertyContribution)1 InvalidCommandException (net.robinfriedli.aiode.exceptions.InvalidCommandException)1