Search in sources :

Example 56 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project BoltBot by DiscordBolt.

the class PlaylistCommand method playlistListCommand.

@BotCommand(command = { "playlist", "list" }, module = MusicModule.MODULE, aliases = "pl", allowPM = true, description = "List all stored playlists", usage = "Playlist list", allowedChannels = "music", args = 2)
public static void playlistListCommand(CommandContext cc) throws CommandException {
    EmbedBuilder embed = new EmbedBuilder();
    embed.withColor(MusicModule.EMBED_COLOR);
    embed.withAuthorName("Playlists");
    List<Playlist> playlists = MusicModule.getPlaylistManager().getPlaylists();
    embed.withTitle("Number of Playlists:");
    embed.withDescription(playlists.size() + "");
    IUser currentUser = null;
    StringBuilder sb = new StringBuilder();
    int id = 1;
    for (Playlist pl : playlists) {
        if (currentUser == null || !pl.getOwnerID().equals(currentUser.getLongID())) {
            if (currentUser != null)
                embed.appendField(currentUser.getName(), sb.toString(), false);
            sb.setLength(0);
            currentUser = pl.getOwner();
        }
        if (sb.length() != 0)
            sb.append('\n');
        sb.append(id++).append(". ").append(pl.getTitle());
    }
    if (currentUser != null)
        embed.appendField(currentUser.getName(), sb.toString(), false);
    cc.replyWith(embed.build());
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) Playlist(com.discordbolt.boltbot.modules.music.playlists.Playlist) IUser(sx.blah.discord.handle.obj.IUser) BotCommand(com.discordbolt.api.command.BotCommand)

Example 57 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project BoltBot by DiscordBolt.

the class ListRoles method listRolesCommand.

@BotCommand(command = "ListRoles", module = "Administration", description = "List the roles of the guild and their ID.", usage = "ListRoles", permissions = Permissions.MANAGE_ROLES)
public static void listRolesCommand(CommandContext cc) {
    StringBuilder sb = new StringBuilder("```");
    for (IRole r : cc.getGuild().getRoles()) {
        sb.append(String.format("%-33s%-18s%n", r.getName(), r.getStringID()));
    }
    EmbedBuilder embed = new EmbedBuilder();
    embed.withAuthorName(cc.getGuild().getName() + "'s Roles");
    embed.withAuthorIcon(cc.getGuild().getIconURL());
    embed.withColor(36, 153, 153);
    embed.setLenient(true);
    embed.withFooterIcon(cc.getAuthor().getAvatarURL());
    embed.withFooterText("Requested by " + cc.getAuthor().getName());
    embed.appendDescription(sb.append("```").toString());
    embed.withTimestamp(System.currentTimeMillis());
    cc.replyWith(embed.build());
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) IRole(sx.blah.discord.handle.obj.IRole) BotCommand(com.discordbolt.api.command.BotCommand)

Example 58 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project BoltBot by DiscordBolt.

the class DiceModule method getDieEmbed.

private static EmbedObject getDieEmbed(int numDice, int numSides) {
    int[] results = roll(numSides, numDice);
    int total = Arrays.stream(results).sum();
    EmbedBuilder embed = new EmbedBuilder();
    embed.withColor(EMBED_COLOR);
    if (numSides == 2 && numDice == 1) {
        embed.withTitle(total == 1 ? "Heads" : "Tails");
    } else {
        embed.withTitle(Integer.toString(total));
    }
    if (numDice > 1) {
        embed.withDescription(EmbedUtil.ZERO_WIDTH_SPACE);
        embed.appendField(numDice + "d" + numSides, Arrays.stream(results).mapToObj(i -> ((Integer) i).toString()).collect(Collectors.joining(" + ")), false);
    } else {
        embed.withDescription(numDice + "d" + numSides);
    }
    embed.withThumbnail(getDieURL(numSides, total, 250));
    return embed.build();
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder)

Example 59 with EmbedBuilder

use of sx.blah.discord.util.EmbedBuilder in project BoltBot by DiscordBolt.

the class MusicModule method createPlayingEmbed.

public static EmbedObject createPlayingEmbed(IGuild guild, AudioTrack track) {
    EmbedBuilder embed = new EmbedBuilder();
    embed.withColor(MusicModule.EMBED_COLOR);
    embed.withTitle(":musical_note: " + track.getInfo().title);
    // embed.withAuthorUrl(track.getInfo().uri);
    embed.withDescription(getVoiceManager().getTrackRequester(guild, track) != null ? "Requested by: " + getVoiceManager().getTrackRequester(guild, track) : "Unknown Requester");
    if (track.getInfo().uri.toLowerCase().contains("youtu")) {
        embed.withThumbnail("https://img.youtube.com/vi/" + track.getIdentifier() + "/0.jpg");
    }
    return embed.build();
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder)

Example 60 with EmbedBuilder

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

the class WeaponScout 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) {
        scoutMenu.withAuthorName(SELECTED_BANNER.getBannerName());
        setupScoutMenu();
        if (!generateImage || IMAGE_DISABLED)
            scoutMenu.appendField("- Weapon Result -", weaponString, false);
        scoutMenu.withAuthorIcon(new GitHubImage("images/System/Scout_Icon.png").getURL());
        scoutMenu.withColor(139, 69, 19);
        if (weapons.get(0).getRarity() == 2)
            scoutMenu.withThumbnail(new GitHubImage("images/System/Brown_Chest.png").getURL());
        else if (weapons.get(0).getRarity() == 3)
            scoutMenu.withThumbnail(new GitHubImage("images/System/Blue_Chest.png").getURL());
        else if (weapons.get(0).getRarity() == 4)
            scoutMenu.withThumbnail(new GitHubImage("images/System/Red_Chest.png").getURL());
        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();
        if (!generateImage || IMAGE_DISABLED) {
            simpleMessage += "**- Weapon Result -**" + "\n";
            simpleMessage += weaponString;
        }
        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 : 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)

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