Search in sources :

Example 6 with GuildPropertyManager

use of net.robinfriedli.aiode.discord.property.GuildPropertyManager 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)

Example 7 with GuildPropertyManager

use of net.robinfriedli.aiode.discord.property.GuildPropertyManager in project aiode by robinfriedli.

the class VoiceChannelListener method isAutoPauseEnabled.

private boolean isAutoPauseEnabled(Guild guild) {
    return hibernateComponent.invokeWithSession(session -> {
        GuildPropertyManager guildPropertyManager = Aiode.get().getGuildPropertyManager();
        GuildManager guildManager = Aiode.get().getGuildManager();
        GuildSpecification specification = guildManager.getContextForGuild(guild).getSpecification(session);
        return guildPropertyManager.getPropertyValueOptional("enableAutoPause", Boolean.class, specification).orElse(true);
    });
}
Also used : GuildManager(net.robinfriedli.aiode.discord.GuildManager) GuildSpecification(net.robinfriedli.aiode.entities.GuildSpecification) GuildPropertyManager(net.robinfriedli.aiode.discord.property.GuildPropertyManager)

Example 8 with GuildPropertyManager

use of net.robinfriedli.aiode.discord.property.GuildPropertyManager in project aiode by robinfriedli.

the class QueueIterator method shouldSendPlaybackNotification.

private boolean shouldSendPlaybackNotification() {
    return StaticSessionProvider.invokeWithSession(session -> {
        Guild guild = playback.getGuild();
        GuildSpecification specification = Aiode.get().getGuildManager().getContextForGuild(guild).getSpecification(session);
        GuildPropertyManager guildPropertyManager = Aiode.get().getGuildPropertyManager();
        return guildPropertyManager.getPropertyValueOptional("sendPlaybackNotification", Boolean.class, specification).orElse(true);
    });
}
Also used : GuildSpecification(net.robinfriedli.aiode.entities.GuildSpecification) Guild(net.dv8tion.jda.api.entities.Guild) GuildPropertyManager(net.robinfriedli.aiode.discord.property.GuildPropertyManager)

Example 9 with GuildPropertyManager

use of net.robinfriedli.aiode.discord.property.GuildPropertyManager in project aiode by robinfriedli.

the class ColorSchemeProperty method getColor.

public static Color getColor() {
    GuildPropertyManager guildPropertyManager = Aiode.get().getGuildPropertyManager();
    ColorSchemeProperty colorProperty = (ColorSchemeProperty) guildPropertyManager.getProperty("color");
    if (colorProperty != null) {
        if (ExecutionContext.Current.isSet()) {
            return colorProperty.getAsColor();
        } else {
            return ColorSchemeProperty.parseColor(colorProperty.getDefaultValue());
        }
    }
    return DEFAULT_FALLBACK;
}
Also used : GuildPropertyManager(net.robinfriedli.aiode.discord.property.GuildPropertyManager)

Example 10 with GuildPropertyManager

use of net.robinfriedli.aiode.discord.property.GuildPropertyManager in project aiode by robinfriedli.

the class PrefixProperty method getForContext.

public static String getForContext(GuildContext guildContext, Session session) {
    GuildSpecification specification = guildContext.getSpecification(session);
    GuildPropertyManager guildPropertyManager = Aiode.get().getGuildPropertyManager();
    return guildPropertyManager.getPropertyValueOptional("prefix", String.class, specification).orElse(DEFAULT_FALLBACK);
}
Also used : GuildSpecification(net.robinfriedli.aiode.entities.GuildSpecification) GuildPropertyManager(net.robinfriedli.aiode.discord.property.GuildPropertyManager)

Aggregations

GuildPropertyManager (net.robinfriedli.aiode.discord.property.GuildPropertyManager)10 GuildSpecification (net.robinfriedli.aiode.entities.GuildSpecification)8 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)3 AbstractGuildProperty (net.robinfriedli.aiode.discord.property.AbstractGuildProperty)3 Guild (net.dv8tion.jda.api.entities.Guild)2 Strings (com.google.common.base.Strings)1 Sets (com.google.common.collect.Sets)1 AudioPlayer (com.sedmelluq.discord.lavaplayer.player.AudioPlayer)1 IOException (java.io.IOException)1 Instant (java.time.Instant)1 LocalDateTime (java.time.LocalDateTime)1 ZoneId (java.time.ZoneId)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 Member (net.dv8tion.jda.api.entities.Member)1 MessageChannel (net.dv8tion.jda.api.entities.MessageChannel)1