Search in sources :

Example 6 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project S-argo by Expugn.

the class TicketScout method displayAndSave.

/**
 * Displays the scout results to the channel where the command
 * was requested and save the results to the user file afterwards.
 * If the results fail to display for any reason then the user file
 * is not saved.
 */
void displayAndSave() {
    if (!SIMPLE_MESSAGE) {
        setupScoutMenu();
        if (!generateImage || IMAGE_DISABLED)
            scoutMenu.appendField("- Weapon Result -", itemString, false);
        scoutMenu.withAuthorIcon(new GitHubImage("images/System/Scout_Icon.png").getURL());
        scoutMenu.withColor(255, 255, 255);
        scoutMenu.withFooterIcon(new GitHubImage("images/System/Memory_Diamond_Icon.png").getURL());
        scoutMenu.withFooterText((CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + userTotalScouts + " Total Ticket Scouts");
        IMessage display = null;
        try {
            if (generateImage && !IMAGE_DISABLED)
                display = CHANNEL.sendFile(scoutMenu.build(), new File(tempUserDirectory + "/results.png"));
            else
                display = CHANNEL.sendMessage(scoutMenu.build());
        } catch (FileNotFoundException e) {
            CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
            display.delete();
            deleteTempDirectory();
            return;
        } catch (RateLimitException e) {
            EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
            try {
                display.edit(rateLimited.build());
            } catch (NullPointerException a) {
            // DO SOMETHING
            }
            deleteTempDirectory();
            return;
        }
    } else {
        setupScoutMenu();
        if (!generateImage || IMAGE_DISABLED) {
            simpleMessage += "**- Weapon Result -**" + "\n";
            simpleMessage += itemString;
        }
        simpleMessage += (CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + userTotalScouts + " Total Ticket Scouts";
        IMessage display = null;
        try {
            if (generateImage && !IMAGE_DISABLED) {
                display = CHANNEL.sendFile(simpleMessage, new File(tempUserDirectory + "/results.png"));
            } else {
                display = CHANNEL.sendMessage(simpleMessage);
            }
        } catch (FileNotFoundException e) {
            CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
            display.delete();
            deleteTempDirectory();
            return;
        } catch (RateLimitException e) {
            EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
            try {
                display.edit(rateLimited.build());
            } catch (NullPointerException a) {
            // DO SOMETHING
            }
            deleteTempDirectory();
            return;
        }
    }
    USER.upgradeExchangeSwords();
    USER.saveData();
    deleteTempDirectory();
}
Also used : WarningMessage(io.github.spugn.Sargo.Objects.WarningMessage) EmbedBuilder(sx.blah.discord.util.EmbedBuilder) RateLimitException(sx.blah.discord.util.RateLimitException) GitHubImage(io.github.spugn.Sargo.Utilities.GitHubImage) IMessage(sx.blah.discord.handle.obj.IMessage) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File)

Example 7 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project S-argo by Expugn.

the class SargoException method getEmbedObject.

protected EmbedObject getEmbedObject(String title, String content, int errorCode) {
    EmbedBuilder builder = new EmbedBuilder();
    builder.withTitle(title);
    builder.withDescription(content);
    builder.withFooterText("Error Code: " + errorCode);
    builder.withColor(255, 0, 0);
    return builder.build();
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder)

Example 8 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project KaellyBot by Kaysoro.

the class Item method getMoreEmbedObject.

@Override
public EmbedObject getMoreEmbedObject(Language lg) {
    EmbedBuilder builder = new EmbedBuilder();
    builder.withTitle(name);
    builder.withUrl(url);
    if (description != null && !description.isEmpty())
        builder.withDescription(description);
    builder.withColor(new Random().nextInt(16777216));
    builder.withImage(skinURL);
    if (level != null && !level.isEmpty())
        builder.appendField(Translator.getLabel(lg, "item.niveau"), level, true);
    builder.appendField(Translator.getLabel(lg, "item.type"), type, true);
    if (effects != null && !effects.isEmpty())
        builder.appendField(Translator.getLabel(lg, "item.effets"), effects, true);
    if (caracteristics != null && !caracteristics.isEmpty())
        builder.appendField(Translator.getLabel(lg, "item.caracteristiques"), caracteristics, true);
    if (conditions != null && !conditions.isEmpty())
        builder.appendField(Translator.getLabel(lg, "item.conditions"), conditions, true);
    if (panoplie != null && panoplieURL != null)
        builder.appendField(Translator.getLabel(lg, "item.panoplie"), "[" + panoplie + "](" + panoplieURL + ")", true);
    if (recipe != null)
        builder.appendField(Translator.getLabel(lg, "item.recette"), recipe, true);
    return builder.build();
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) Random(java.util.Random)

Example 9 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project KaellyBot by Kaysoro.

the class Monster method getMoreEmbedObject.

@Override
public EmbedObject getMoreEmbedObject(Language lg) {
    EmbedBuilder builder = new EmbedBuilder();
    builder.withTitle(name);
    builder.withUrl(url);
    builder.withColor(new Random().nextInt(16777216));
    builder.withImage(skinURL);
    if (level != null && !level.isEmpty())
        builder.appendField(Translator.getLabel(lg, "monster.level"), level, true);
    builder.appendField(Translator.getLabel(lg, "monster.race"), family, true);
    if (caracteristics != null && !caracteristics.isEmpty())
        builder.appendField(Translator.getLabel(lg, "monster.caracteristic"), caracteristics, true);
    if (resistances != null && !resistances.isEmpty())
        builder.appendField(Translator.getLabel(lg, "monster.resistance"), resistances, true);
    if (zones != null && !zones.isEmpty())
        builder.appendField(Translator.getLabel(lg, "monster.zones"), zones, true);
    if (!butins.isEmpty())
        for (int i = 0; i < butins.size(); i++) builder.appendField(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++) builder.appendField(Translator.getLabel(lg, "monster.butins_conditionnes") + (butinsConditionne.size() > 1 ? " (" + (i + 1) + "/" + butinsConditionne.size() + ")" : "") + " : ", butinsConditionne.get(i), true);
    return builder.build();
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) Random(java.util.Random)

Example 10 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project KaellyBot by Kaysoro.

the class Portal method getEmbedObject.

@Override
public EmbedObject getEmbedObject(Language lg) {
    EmbedBuilder builder = new EmbedBuilder();
    builder.withTitle(name);
    builder.withColor(getColor());
    builder.withThumbnail(url);
    if (!isValid()) {
        coordonate = new Position();
        utilisation = -1;
        builder.withDescription(Translator.getLabel(lg, "portal.unknown"));
    } else {
        builder.appendField(Translator.getLabel(lg, "portal.position"), "**" + coordonate + "**", true);
        if (utilisation != -1)
            builder.appendField(Translator.getLabel(lg, "portal.utilisation.title"), utilisation + " " + Translator.getLabel(lg, "portal.utilisation.desc") + (utilisation > 1 ? "s" : ""), true);
        if (transportLimited != null)
            builder.appendField(Translator.getLabel(lg, "portal.private_zaap"), transportLimited.toDiscordString(lg), false);
        builder.appendField(Translator.getLabel(lg, "portal.zaap"), zaap.toDiscordString(lg), false);
        builder.withFooterText(getDateInformation(creationSource, updateSource, lg));
    }
    return builder.build();
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder)

Aggregations

EmbedBuilder (sx.blah.discord.util.EmbedBuilder)103 IOException (java.io.IOException)19 Random (java.util.Random)17 IUser (sx.blah.discord.handle.obj.IUser)14 MissingArgumentException (me.shadorc.shadbot.exception.MissingArgumentException)13 LoadingMessage (me.shadorc.shadbot.utils.object.LoadingMessage)13 EmbedObject (sx.blah.discord.api.internal.json.objects.EmbedObject)12 JSONObject (org.json.JSONObject)11 IMessage (sx.blah.discord.handle.obj.IMessage)10 List (java.util.List)9 AbstractCommand (me.shadorc.shadbot.core.command.AbstractCommand)9 EmbedUtils (me.shadorc.shadbot.utils.embed.EmbedUtils)9 JSONException (org.json.JSONException)9 EventColor (com.cloudcraftgaming.discal.api.enums.event.EventColor)8 Utils (me.shadorc.shadbot.utils.Utils)8 IChannel (sx.blah.discord.handle.obj.IChannel)8 EventData (com.cloudcraftgaming.discal.api.object.event.EventData)7 FormatUtils (me.shadorc.shadbot.utils.FormatUtils)7 File (java.io.File)6 CommandCategory (me.shadorc.shadbot.core.command.CommandCategory)6