Search in sources :

Example 1 with Relic

use of me.shadorc.shadbot.data.premium.Relic in project Shadbot by Shadorc.

the class RelicStatusCmd method execute.

@Override
public void execute(Context context) throws MissingArgumentException {
    List<Relic> relics = PremiumManager.getRelicsForUser(context.getAuthor().getLongID());
    if (relics.isEmpty()) {
        BotUtils.sendMessage(String.format(Emoji.INFO + " You are not a donator. If you like Shadbot, you can help me keep it alive" + " by making a donation on **%s**.%nAll donations are important and really help me %s", Config.PATREON_URL, Emoji.HEARTS), context.getChannel());
        return;
    }
    EmbedBuilder embed = EmbedUtils.getDefaultEmbed().withAuthorName("Contributor status").withThumbnail("https://orig00.deviantart.net/24e1/f/2015/241/8/7/relic_fragment_by_yukimemories-d97l8c8.png");
    for (Relic relic : relics) {
        StringBuilder contentBld = new StringBuilder();
        contentBld.append(String.format("**ID:** %s", relic.getRelicID()));
        if (relic.getType().equals(RelicType.GUILD)) {
            contentBld.append(String.format("%n**Guild ID:** %d", relic.getGuildID()));
        }
        contentBld.append(String.format("%n**Duration:** %d days", relic.getDuration()));
        if (!relic.isExpired()) {
            long daysLeft = relic.getDuration() - TimeUnit.MILLISECONDS.toDays(TimeUtils.getMillisUntil(relic.getActivationTime()));
            contentBld.append(String.format("%n**Expires in:** %d days", daysLeft));
        }
        StringBuilder titleBld = new StringBuilder();
        if (relic.getType().equals(RelicType.GUILD)) {
            titleBld.append("Legendary ");
        }
        titleBld.append(String.format("Relic (%s)", relic.isExpired() ? "Expired" : "Activated"));
        embed.appendField(titleBld.toString(), contentBld.toString(), false);
    }
    BotUtils.sendMessage(embed.build(), context.getChannel());
}
Also used : Relic(me.shadorc.shadbot.data.premium.Relic) EmbedBuilder(sx.blah.discord.util.EmbedBuilder)

Example 2 with Relic

use of me.shadorc.shadbot.data.premium.Relic in project Shadbot by Shadorc.

the class GenerateRelicCmd method execute.

@Override
public void execute(Context context) throws MissingArgumentException, IllegalCmdArgumentException {
    if (!context.hasArg()) {
        throw new MissingArgumentException();
    }
    RelicType type = Utils.getValueOrNull(RelicType.class, context.getArg());
    if (type == null) {
        throw new IllegalCmdArgumentException(String.format("`%s`in not a valid type. %s", context.getArg(), FormatUtils.formatOptions(RelicType.class)));
    }
    Relic relic = PremiumManager.generateRelic(type);
    BotUtils.sendMessage(String.format(Emoji.CHECK_MARK + " %s relic generated: **%s**", StringUtils.capitalize(type.toString()), relic.getRelicID()), context.getChannel());
}
Also used : IllegalCmdArgumentException(me.shadorc.shadbot.exception.IllegalCmdArgumentException) Relic(me.shadorc.shadbot.data.premium.Relic) MissingArgumentException(me.shadorc.shadbot.exception.MissingArgumentException) RelicType(me.shadorc.shadbot.data.premium.RelicType)

Aggregations

Relic (me.shadorc.shadbot.data.premium.Relic)2 RelicType (me.shadorc.shadbot.data.premium.RelicType)1 IllegalCmdArgumentException (me.shadorc.shadbot.exception.IllegalCmdArgumentException)1 MissingArgumentException (me.shadorc.shadbot.exception.MissingArgumentException)1 EmbedBuilder (sx.blah.discord.util.EmbedBuilder)1