Search in sources :

Example 1 with EmbedBuilder

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

the class AboutCommand method request.

@Override
public boolean request(IMessage message) {
    if (super.request(message)) {
        IUser author = ClientConfig.DISCORD().getApplicationOwner();
        EmbedBuilder builder = new EmbedBuilder();
        Language lg = Translator.getLanguageFrom(message.getChannel());
        builder.withTitle(Translator.getLabel(lg, "about.title").replace("{name}", Constants.name).replace("{version}", Constants.version)).withDesc(Translator.getLabel(lg, "about.desc").replace("{game}", Constants.game)).withColor(new Random().nextInt(16777216)).withThumbnail(ClientConfig.DISCORD().getApplicationIconURL()).withAuthorName(author.getName()).withAuthorIcon(author.getAvatarURL()).withImage(Constants.changelog);
        ;
        builder.appendField(Translator.getLabel(lg, "about.invite.title"), Translator.getLabel(lg, "about.invite.desc").replace("{name}", Constants.name).replace("{invite}", Constants.invite), true).appendField(Translator.getLabel(lg, "about.support.title"), Translator.getLabel(lg, "about.support.desc").replace("{name}", Constants.name).replace("{discordInvite}", Constants.discordInvite), true).appendField(Translator.getLabel(lg, "about.twitter.title"), Translator.getLabel(lg, "about.twitter.desc").replace("{name}", Constants.name).replace("{twitter}", Constants.twitterAccount), true).appendField(Translator.getLabel(lg, "about.opensource.title"), Translator.getLabel(lg, "about.opensource.desc").replace("{git}", Constants.git), true).appendField(Translator.getLabel(lg, "about.free.title"), Translator.getLabel(lg, "about.free.desc").replace("{paypal}", Constants.paypal), true);
        StringBuilder st = new StringBuilder();
        for (Donator donator : Donator.values()) st.append(donator.getName()).append(", ");
        st.setLength(st.length() - 2);
        builder.appendField(Translator.getLabel(lg, "about.donators.title"), st.toString() + ".", true);
        Message.sendEmbed(message.getChannel(), builder.build());
        return true;
    }
    return false;
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) Language(enums.Language) Random(java.util.Random) Donator(enums.Donator) IUser(sx.blah.discord.handle.obj.IUser)

Example 2 with EmbedBuilder

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

the class Profile method init.

/**
 * Initializes the EmbedMessage and variables.
 */
private void init() {
    builder = new EmbedBuilder();
    iUser = CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID));
    user = new UserParser(DISCORD_ID);
    userName = iUser.getName() + "#" + iUser.getDiscriminator();
    goldCount = 0;
    platinumCount = 0;
    bannerType = new TreeMap<>();
    builder.withAuthorName(userName + "'s Profile");
    builder.withAuthorIcon(iUser.getAvatarURL());
    builder.withColor(255, 86, 91);
    builder.withThumbnail(new GitHubImage("images/System/Profile_Icon.png").getURL());
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) UserParser(io.github.spugn.Sargo.XMLParsers.UserParser) GitHubImage(io.github.spugn.Sargo.Utilities.GitHubImage)

Example 3 with EmbedBuilder

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

the class CharacterScout 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() {
    ScoutMasterParser smp = new ScoutMasterParser();
    if (!SIMPLE_MESSAGE) {
        scoutMenu.withAuthorName(SELECTED_BANNER.getBannerName());
        setupScoutMenu();
        if (!generateImage || IMAGE_DISABLED)
            scoutMenu.appendField("- Scout Result -", characterString, false);
        scoutMenu.withDesc(smp.getQuote());
        scoutMenu.withAuthorIcon(new GitHubImage("images/System/Scout_Icon.png").getURL());
        scoutMenu.withColor(244, 233, 167);
        scoutMenu.withThumbnail(smp.getImage(highestRarity));
        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()) + " | " + USER.getMemoryDiamonds() + " Memory Diamonds Left");
        LOGGER.debug("Displaying Scout Result...");
        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 {
        simpleMessage += "**" + SELECTED_BANNER.getBannerName() + "**" + "\n";
        setupScoutMenu();
        simpleMessage += smp.getQuote() + "\n";
        if (!generateImage || IMAGE_DISABLED) {
            simpleMessage += "**- Scout Result -**" + "\n";
            simpleMessage += characterString;
        }
        simpleMessage += (CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + USER.getMemoryDiamonds() + " Memory Diamonds Left";
        LOGGER.debug("Displaying Scout Result...");
        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;
        }
    }
    LOGGER.debug("Saving User Data...");
    USER.saveData();
    deleteTempDirectory();
}
Also used : ScoutMasterParser(io.github.spugn.Sargo.XMLParsers.ScoutMasterParser) 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 4 with EmbedBuilder

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

the class CharacterScout method init.

/**
 * Initializes all the variables needed for scouts.
 */
private void init() {
    /* FILES */
    // SETTINGS = new SettingsParser();
    BANNERS = BannerParser.getBanners();
    USER = new UserParser(DISCORD_ID);
    /* SETTINGS */
    IS_RARITY_STARS = SettingsParser.isRarityStars();
    COPPER = (int) (SettingsParser.getCopperRates() * 100);
    SILVER = (int) (SettingsParser.getSilverRates() * 100);
    GOLD = (int) (SettingsParser.getGoldRates() * 100);
    PLATINUM = (int) (SettingsParser.getPlatinumRates() * 100);
    RECORD_CRYSTAL_RATES = SettingsParser.getRecordCrystalRates();
    CIRCULATING_RECORD_CRYSTAL_RATES = SettingsParser.getCirculatingRecordCrystalRates();
    GOLD_BANNERS = SettingsParser.getGoldBanners();
    GOLD_BANNERS_V2 = SettingsParser.getGoldBannersv2();
    IMAGE_DISABLED = SettingsParser.isDisableImages();
    SIMPLE_MESSAGE = SettingsParser.isSimpleMessage();
    /* USER */
    userMemoryDiamonds = USER.getMemoryDiamonds();
    userHackingCrystals = USER.getHackingCrystals();
    userRecordCrystals = 0;
    /* VARIABLES */
    RNG = new Random(System.currentTimeMillis());
    imageStrings = new String[11];
    characters = new ArrayList<>();
    guaranteeOnePlatinum = false;
    guaranteedScout = false;
    characterString = "";
    tempUserDirectory = new File("images/temp_" + DISCORD_ID);
    scoutMenu = new EmbedBuilder();
    simpleMessage = "";
    /* MEMORY DIAMOND PRICES */
    singleScoutPrice = 25;
    multiScoutPrice = 250;
    /* BANNER */
    if (BANNER_ID < BANNERS.size() && BANNER_ID >= 0) {
        SELECTED_BANNER = BANNERS.get(BANNER_ID);
        BANNER_CHARACTERS = SELECTED_BANNER.getCharacters();
        bannerType = SELECTED_BANNER.getBannerType();
        bannerTypeData = USER.getBannerData(SELECTED_BANNER.getBannerName());
        goldCharacters = new ArrayList<>();
        platinumCharacters = new ArrayList<>();
        if (USER.isBannerInfoExists(SELECTED_BANNER.getBannerName()) == -1) {
            initBannerInfo();
        }
        for (Character character : BANNER_CHARACTERS) {
            if (character.getRarity() == 4) {
                goldCharacters.add(character);
            } else if (character.getRarity() == 5) {
                platinumCharacters.add(character);
            }
        }
        if (platinumCharacters.size() <= 0) {
            COPPER += PLATINUM;
            PLATINUM = 0;
        }
        modifyScoutData();
        LOGGER.debug("\n- Scout Data -\n" + "Single Price " + singleScoutPrice + "\n" + "Multi Price: " + multiScoutPrice + "\n" + "COPPER: " + COPPER + "%\n" + "SILVER: " + SILVER + "%\n" + "GOLD: " + GOLD + "%\n" + "PLATINUM: " + PLATINUM + "%");
    }
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) Random(java.util.Random) Character(io.github.spugn.Sargo.Objects.Character) UserParser(io.github.spugn.Sargo.XMLParsers.UserParser) File(java.io.File)

Example 5 with EmbedBuilder

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

the class TicketScout method init.

/**
 * Initializes all the variables needed for scouts.
 */
private void init() {
    /* FILES */
    // SettingsParser SETTINGS = new SettingsParser();
    USER = new UserParser(DISCORD_ID);
    /* SETTINGS */
    // IMAGE_DISABLED = SETTINGS.isDisableImages();
    // SIMPLE_MESSAGE = SETTINGS.isSimpleMessage();
    // IS_RARITY_STARS = SETTINGS.isRarityStars();
    IMAGE_DISABLED = SettingsParser.isDisableImages();
    SIMPLE_MESSAGE = SettingsParser.isSimpleMessage();
    IS_RARITY_STARS = SettingsParser.isRarityStars();
    /* USER */
    userColBalance = USER.getColBalance();
    userTotalScouts = USER.getTotalTicketScout();
    /* VARIABLES */
    RNG = new Random(System.currentTimeMillis());
    scoutMenu = new EmbedBuilder();
    simpleMessage = "";
    imageStrings = new String[11];
    items = new ArrayList<>();
    itemString = "";
    tempUserDirectory = new File("images/temp_" + DISCORD_ID);
    attributeItemsList = new ArrayList<>();
    medallionsAndKeyList = new ArrayList<>();
    /* ITEMS */
    initItems();
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) Random(java.util.Random) UserParser(io.github.spugn.Sargo.XMLParsers.UserParser) File(java.io.File)

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