Java Code Examples for discord4j.core.spec.EmbedCreateSpec#addField()

The following examples show how to use discord4j.core.spec.EmbedCreateSpec#addField() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Almanax.java    From KaellyBot with GNU General Public License v3.0 6 votes vote down vote up
public static void decorateGroupedObject(EmbedCreateSpec spec, Language lg, Date day, int occurrence) throws IOException {
    Date firstDate = DateUtils.addDays(day,1);
    Date lastDate = DateUtils.addDays(day, occurrence);
    String title = Translator.getLabel(lg, "almanax.embed.title.1") + " " + discordToBot.format(firstDate) +
            (occurrence > 1 ? " " + Translator.getLabel(lg, "almanax.embed.title.2") + " " + discordToBot.format(lastDate) : "");

    spec.setTitle(title)
        .setColor(Color.GRAY);

    for (int i = 1; i <= occurrence; i++) {
        firstDate = DateUtils.addDays(new Date(), i);
        Almanax almanax = Almanax.get(lg, firstDate);
        spec.addField(discordToBot.format(firstDate), Translator.getLabel(lg, "almanax.embed.bonus")
                + " " + almanax.getBonus() + "\n" + Translator.getLabel(lg, "almanax.embed.offrande")
                + " " + almanax.getOffrande(), true);
    }
}
 
Example 2
Source File: Item.java    From KaellyBot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void decorateEmbedObject(EmbedCreateSpec spec, Language lg) {
    spec.setTitle(name)
        .setUrl(url)
        .setColor(Color.GRAY)
        .setThumbnail(skinURL);

    if (level != null && ! level.isEmpty())
        spec.addField(Translator.getLabel(lg, "item.niveau"), level, true);
    spec.addField(Translator.getLabel(lg, "item.type"), type, true);

    if (effects != null && ! effects.isEmpty())
    spec.addField(Translator.getLabel(lg, "item.effets"), effects, true);

    if (caracteristics != null && ! caracteristics.isEmpty())
        spec.addField(Translator.getLabel(lg, "item.caracteristiques"), caracteristics, true);

    if (conditions != null && ! conditions.isEmpty())
        spec.addField(Translator.getLabel(lg, "item.conditions"), conditions, true);

    if (panoplie != null && panoplieURL != null)
        spec.addField(Translator.getLabel(lg, "item.panoplie"), "[" + panoplie + "](" + panoplieURL + ")", true);
}
 
Example 3
Source File: DofusGuild.java    From KaellyBot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void decorateEmbedObject(EmbedCreateSpec spec, Language lg){
    spec.setTitle(name)
    .setUrl(url)
    .setDescription(Translator.getLabel(lg, "guild.desc"))
    .setColor(Color.GRAY)
    .setThumbnail(littleSkinURL)
    .setImage(bigSkinURL)
    .addField(Translator.getLabel(lg, "guild.level"), level, true)
    .addField(Translator.getLabel(lg, "guild.server"), server, true)
    .addField(Translator.getLabel(lg, "guild.creation_date"), creationDate, true)
    .addField(Translator.getLabel(lg, "guild.members_size"), membersSize, true);

    if (alliName != null)
        spec.addField(Translator.getLabel(lg, "guild.ally"), "[" + alliName + "](" + alliUrl + ")", true);

    if (! mainMembers.isEmpty())
        for(int i = 0; i < mainMembers.size(); i++)
            spec.addField(Translator.getLabel(lg, "guild.main_members")
                            + (mainMembers.size() > 1? " (" + (i + 1) + "/"
                            + mainMembers.size() + ")" : "") + " : ",
                    mainMembers.get(i), true);
}
 
Example 4
Source File: SetDofus.java    From KaellyBot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void decorateEmbedObject(EmbedCreateSpec spec, Language lg) {
    spec.setTitle(name)
        .setUrl(url)
        .setColor(Color.GRAY)
        .setThumbnail(skinURL);

    if (level != null && ! level.isEmpty())
        spec.addField(Translator.getLabel(lg, "set.level"), level, true);

    if (composition != null && ! composition.isEmpty())
        spec.addField(Translator.getLabel(lg, "set.composition"), composition, true);

    for(int i = 0; i < bonusPano.length; i++)
        if (bonusPano[i] != null)
            spec.addField(Translator.getLabel(lg, "set.bonus.1") + " " + (i + 2)
                    + " " + Translator.getLabel(lg, "set.bonus.2"), bonusPano[i], true);
}
 
Example 5
Source File: Alliance.java    From KaellyBot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void decorateEmbedObject(EmbedCreateSpec spec, Language lg){
    spec.setTitle(name)
        .setUrl(url)
        .setDescription(Translator.getLabel(lg, "alliance.desc"))

        .setColor(Color.GRAY)
        .setThumbnail(littleSkinURL)
        .setImage(bigSkinURL)

        .addField(Translator.getLabel(lg, "alliance.server"), server, true)
        .addField(Translator.getLabel(lg, "alliance.creation_date"), creationDate, true)
        .addField(Translator.getLabel(lg, "alliance.guilds_size"), guildsSize, true)
        .addField(Translator.getLabel(lg, "alliance.members_size"), membersSize, true);

    if (! few_members.isEmpty())
        for(int i = 0; i < few_members.size(); i++)
            spec.addField(Translator.getLabel(lg, "alliance.few_members")
                            + (few_members.size() > 1? " (" + (i + 1) + "/"
                            + few_members.size() + ")" : "") + " : ",
                    few_members.get(i), true);
}
 
Example 6
Source File: Monster.java    From KaellyBot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void decorateEmbedObject(EmbedCreateSpec spec, Language lg) {
    spec.setTitle(name)
        .setUrl(url)
        .setColor(Color.GRAY)
        .setThumbnail(skinURL);

    if (level != null && ! level.isEmpty())
        spec.addField(Translator.getLabel(lg, "monster.level"), level, true);
    spec.addField(Translator.getLabel(lg, "monster.race"), family, true);

    if (caracteristics != null && ! caracteristics.isEmpty())
        spec.addField(Translator.getLabel(lg, "monster.caracteristic"), caracteristics, true);

    if (resistances != null && ! resistances.isEmpty())
        spec.addField(Translator.getLabel(lg, "monster.resistance"), resistances, true);

    if (error) spec.setFooter(Translator.getLabel(lg, "monster.error"), null);
}
 
Example 7
Source File: Character.java    From KaellyBot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void decorateMoreEmbedObject(EmbedCreateSpec spec, Language lg) {
    spec.setTitle(pseudo)
        .setUrl(url)
        .setDescription(classe + ", " + level)
        .setColor(Color.GRAY)
        .setThumbnail(littleSkinURL)
        .setFooter(Translator.getLabel(lg, "whois.server") + " " + server, null);

    if (stuffAvailable){
        spec.setImage(bigSkinURL)
            .addField(Translator.getLabel(lg, "whois.stuff.primary"), primaire, true)
            .addField(Translator.getLabel(lg, "whois.stuff.secondary"), secondaire, true)
            .addField(Translator.getLabel(lg, "whois.stuff.damages"), dommage, true)
            .addField(Translator.getLabel(lg, "whois.stuff.resistances"), resistance, true);
    }
    else {
        String[] punchlines = Translator.getLabel(lg, "whois.stuff.none.punchlines").split(";");
        String punchline = punchlines[new Random().nextInt(punchlines.length)];
        spec.addField(Translator.getLabel(lg, "whois.stuff.none.title"), punchline, true);
    }
}
 
Example 8
Source File: Resource.java    From KaellyBot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void decorateEmbedObject(EmbedCreateSpec spec, Language lg) {
    spec.setTitle(name)
        .setUrl(url)
        .setColor(Color.GRAY)
        .setThumbnail(skinURL);

    if (level != null && ! level.isEmpty())
        spec.addField(Translator.getLabel(lg, "resource.niveau"), level, true);
    spec.addField(Translator.getLabel(lg, "resource.type"), type, true);

    if (effects != null && ! effects.isEmpty())
        spec.addField(Translator.getLabel(lg, "resource.effets"), effects, true);

    if (bonus != null && ! bonus.isEmpty())
        spec.addField(Translator.getLabel(lg, "resource.bonus"), bonus, true);

    if (sorts != null && ! sorts.isEmpty())
        spec.addField(Translator.getLabel(lg, "resource.sorts"),sorts, true);
}
 
Example 9
Source File: Item.java    From KaellyBot with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void decorateMoreEmbedObject(EmbedCreateSpec spec, Language lg) {
    spec.setTitle(name)
        .setUrl(url)
        .setColor(Color.GRAY)
        .setImage(skinURL);

    if (description != null && ! description.isEmpty())
        spec.setDescription(description);

    if (level != null && ! level.isEmpty())
        spec.addField(Translator.getLabel(lg, "item.niveau"), level, true);
    spec.addField(Translator.getLabel(lg, "item.type"), type, true);

    if (effects != null && ! effects.isEmpty())
        spec.addField(Translator.getLabel(lg, "item.effets"), effects, true);

    if (caracteristics != null && ! caracteristics.isEmpty())
        spec.addField(Translator.getLabel(lg, "item.caracteristiques"), caracteristics, true);

    if (conditions != null && ! conditions.isEmpty())
        spec.addField(Translator.getLabel(lg, "item.conditions"), conditions, true);

    if (panoplie != null && panoplieURL != null)
        spec.addField(Translator.getLabel(lg, "item.panoplie"), "[" + panoplie + "](" + panoplieURL + ")", true);

    if (recipe != null)
        spec.addField(Translator.getLabel(lg, "item.recette"), recipe, true);
}
 
Example 10
Source File: SetDofus.java    From KaellyBot with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void decorateMoreEmbedObject(EmbedCreateSpec spec, Language lg) {
    spec.setTitle(name)
        .setUrl(url)
        .setColor(Color.GRAY)
        .setImage(skinURL);

    if (level != null && ! level.isEmpty())
        spec.addField(Translator.getLabel(lg, "set.level"), level, true);

    if (composition != null && ! composition.isEmpty())
        spec.addField(Translator.getLabel(lg, "set.composition"), composition, true);

    if (bonusTotal != null && ! bonusTotal.isEmpty())
        for(int i = 0; i < bonusTotal.size(); i++)
            spec.addField(Translator.getLabel(lg, "set.bonus.total") + (bonusTotal.size() > 1?
                        " (" + (i + 1) + "/" + bonusTotal.size() + ")" : "") + " : ",
                bonusTotal.get(i), true);

    if (! recipeTotal.isEmpty())
        for(int i = 0; i < recipeTotal.size(); i++)
            spec.addField(Translator.getLabel(lg, "set.recipe") + (recipeTotal.size() > 1?
                            " (" + (i + 1) + "/" + recipeTotal.size() + ")" : "") + " : ",
                    recipeTotal.get(i), true);

    for(int i = 0; i < bonusPano.length; i++)
        spec.addField(Translator.getLabel(lg, "set.bonus.1") + " " + (i + 2)
                + " " + Translator.getLabel(lg, "set.bonus.2"), bonusPano[i], true);
}
 
Example 11
Source File: Monster.java    From KaellyBot with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void decorateMoreEmbedObject(EmbedCreateSpec spec, Language lg) {
    spec.setTitle(name)
        .setUrl(url)
        .setColor(Color.GRAY)
        .setImage(skinURL);

    if (level != null && ! level.isEmpty())
        spec.addField(Translator.getLabel(lg, "monster.level"), level, true);
    spec.addField(Translator.getLabel(lg, "monster.race"), family, true);

    if (caracteristics != null && ! caracteristics.isEmpty())
        spec.addField(Translator.getLabel(lg, "monster.caracteristic"), caracteristics, true);

    if (resistances != null && ! resistances.isEmpty())
        spec.addField(Translator.getLabel(lg, "monster.resistance"), resistances, true);

    if (zones != null && ! zones.isEmpty())
        spec.addField(Translator.getLabel(lg, "monster.zones"), zones, true);

    if (! butins.isEmpty())
        for(int i = 0; i < butins.size(); i++)
            spec.addField(Translator.getLabel(lg, "monster.butins")
                            + (butins.size() > 1? " (" + (i + 1) + "/" + butins.size() + ")" : "") + " : ",
                    butins.get(i), true);

    if (! butinsConditionne.isEmpty())
        for(int i = 0; i < butinsConditionne.size(); i++)
            spec.addField(Translator.getLabel(lg, "monster.butins_conditionnes")
                            + (butinsConditionne.size() > 1? " (" + (i + 1) + "/"
                            + butinsConditionne.size() + ")" : "") + " : ",
                    butinsConditionne.get(i), true);

    if (error) spec.setFooter(Translator.getLabel(lg, "monster.error"), null);
}
 
Example 12
Source File: Character.java    From KaellyBot with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void decorateEmbedObject(EmbedCreateSpec spec, Language lg){
    spec.setTitle(pseudo)
        .setUrl(url)
        .setDescription(classe)
        .setColor(Color.GRAY)
        .setThumbnail(littleSkinURL)
        .setImage(bigSkinURL)
        .setFooter(Translator.getLabel(lg, "whois.server") + " " + server, null);

    if (ladderXP != null && ! ladderXP.isEmpty())
        spec.addField(Translator.getLabel(lg, "whois.level") + " " + level, ladderXP, true);
    else
        spec.addField(Translator.getLabel(lg, "whois.level") + " " + level,
                Translator.getLabel(lg, "whois.ladder.none"), true);

    if (ladderSuccess != null && ! ladderSuccess.isEmpty())
        spec.addField(Translator.getLabel(lg, "whois.success") + " " + score,
                ladderSuccess, true);
    else
        spec.addField(Translator.getLabel(lg, "whois.success") + " " + score,
                Translator.getLabel(lg, "whois.ladder.none"), true);

    if (ladderKoli != null && ! ladderKoli.isEmpty())
        spec.addField(Translator.getLabel(lg, "whois.ladder_koli"), ladderKoli, true);

    if (guildName != null)
        spec.addField(Translator.getLabel(lg, "whois.guild"), "[" + guildName + "](" + guildUrl + ")", true);
    if (alliName != null)
        spec.addField(Translator.getLabel(lg, "whois.ally"), "[" + alliName + "](" + alliUrl + ")", true);
}
 
Example 13
Source File: Resource.java    From KaellyBot with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void decorateMoreEmbedObject(EmbedCreateSpec spec, Language lg) {
    spec.setTitle(name)
        .setUrl(url);
    if (description != null && ! description.isEmpty())
        spec.setDescription(description);

    spec.setColor(Color.GRAY)
        .setImage(skinURL);

    if (level != null && ! level.isEmpty())
        spec.addField(Translator.getLabel(lg, "resource.niveau"), level, true);
    spec.addField(Translator.getLabel(lg, "resource.type"), type, true);

    if (effects != null && ! effects.isEmpty())
        spec.addField(Translator.getLabel(lg, "resource.effets"), effects, true);

    if (bonus != null && ! bonus.isEmpty())
        spec.addField(Translator.getLabel(lg, "resource.bonus"), bonus, true);

    if (sorts != null && ! sorts.isEmpty())
        spec.addField(Translator.getLabel(lg, "resource.sorts"),sorts, true);

    if (recipe != null)
        spec.addField(Translator.getLabel(lg, "resource.recette"), recipe, true);

    if (! monsterDrop.isEmpty())
        for(int i = 0; i < monsterDrop.size(); i++)
            spec.addField(Translator.getLabel(lg, "resource.monster")
                            + (monsterDrop.size() > 1? " (" + (i + 1) + "/" + monsterDrop.size() + ")" : "") + " : ",
                    monsterDrop.get(i), true);
}
 
Example 14
Source File: PortalMapper.java    From KaellyBot with GNU General Public License v3.0 5 votes vote down vote up
public static void decorateSpec(EmbedCreateSpec spec, PortalDto portal, Language language){
    Dimension dimension = Dimension.valueOfCaseUnsensitive(portal.getDimension(), language);

    spec.setTitle(portal.getDimension())
            .setThumbnail(dimension.getImage())
            .setColor(dimension.getColor());

    if (Boolean.TRUE.equals(portal.getIsAvailable()) && portal.getNearestZaap() != null
            && portal.getPosition() != null && portal.getUtilisation() > 0){
        spec.addField(Translator.getLabel(language, "portal.position"),
                "**" + portal.getPosition() + "**", true);

        // Utilisation
        spec.addField(Translator.getLabel(language, "portal.utilisation.title"),
                portal.getUtilisation() + " "
                        + Translator.getLabel(language, "portal.utilisation.desc")
                        + (portal.getUtilisation() > 1 ? "s" : ""), true);

        // Transports
        if (portal.getNearestTransportLimited() != null)
            spec.addField(Translator.getLabel(language, "portal.private_zaap")
                            .replace("{transport}", portal.getNearestTransportLimited().getType()),
                    portal.getNearestTransportLimited().toString(), false);

            spec.addField(Translator.getLabel(language, "portal.zaap"),
                    portal.getNearestZaap().toString(), false);

        spec.setFooter(getDateInformation(portal, language),
                "https://i.imgur.com/u2PUyt5.png");
    }
    else
        spec.setDescription(Translator.getLabel(language, "portal.unknown"));
}