Java Code Examples for net.dv8tion.jda.core.EmbedBuilder#setDescription()

The following examples show how to use net.dv8tion.jda.core.EmbedBuilder#setDescription() . 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: BetaCommand.java    From FlareBot with MIT License 6 votes vote down vote up
@Override
public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) {
    String betaInfo =
            FormatUtils.formatCommandPrefix(guild, FlareBot.getCommandManager().getCommands()
                    .stream()
                    .filter(Command::isBetaTesterCommand)
                    .map(c -> "`{%}" + c.getCommand() + "` - " + c.getDescription())
                    .collect(Collectors.joining("\n")));
    String betaMessage = guild.hasBetaAccess() ?
            "Thank you for being apart of our beta program! Please report any bugs or give us suggestions over at the [support discord](" + Constants.INVITE_URL + ")!"
            : "Listed below are the commands you can gain access to by being a part of our beta program! To join the beta program, you will either need to win " +
            "beta access through a giveaway (Make sure you are in the [support server](" + Constants.INVITE_URL + ") to hear of these!) or you can become apart of the " +
            "Donator tier or higher on our [patreon page](https://www.patreon.com/flarebot)!";
    EmbedBuilder builder = MessageUtils.getEmbed(sender);
    builder.setColor(Color.CYAN);
    builder.setDescription(betaMessage);
    builder.addField("Beta Commands", betaInfo, false);
    channel.sendMessage(builder.build()).queue();
}
 
Example 2
Source File: PagedEmbedBuilder.java    From FlareBot with MIT License 6 votes vote down vote up
/**
 * Gets the {@link MessageEmbed} for a specified page.
 *
 * @param page The page to get an embed.
 * @return the {@link MessageEmbed} page.
 */
public MessageEmbed getEmbed(int page) {
    EmbedBuilder pageEmbed = new EmbedBuilder().setColor(ColorUtils.FLAREBOT_BLUE);
    if (title != null)
        pageEmbed.setTitle(title);
    if(useGroups) {
        int start = groupsPerPage * (page);
        int end = Math.min(start + groupsPerPage, groupTotal);
        int num = start;
        List<PaginationList<T>.PageGroup> groups = list.getGroups().subList(start, end);
        for (PaginationList.PageGroup group : groups) {
            pageEmbed.addField(groupPrefix + num, group.getGroupAsString(), false);
            num++;
        }
    } else {
        pageEmbed.setDescription((hasCodeBlock ? "```" + codeBlock + "\n" : "") + list.getPage(page) + (hasCodeBlock ? "\n```" : ""));
    }
    if (pageCounts) {
        pageEmbed.addField("Page", String.valueOf(page + 1), true);
        pageEmbed.addField("Total Pages", String.valueOf(pageTotal), true);
    }
    pageEmbed.setColor(color);
    return pageEmbed.build();
}
 
Example 3
Source File: MessageUtils.java    From FlareBot with MIT License 6 votes vote down vote up
public static void sendMessage(MessageType type, EmbedBuilder builder, TextChannel channel, long autoDeleteDelay) {
    if (builder.build().getColor() == null)
        builder.setColor(type.getColor());
    if (type == MessageType.ERROR) {
        if (flareHeart == null)
            flareHeart = Getters.getEmoteById(386550693294768129L);
        builder.setDescription(builder.build().getDescription() + "\n\nIf you need more support join our " +
                "[Support Server](" + Constants.INVITE_URL + ")! Our staff can support on any issue you may have! "
                + (flareHeart == null ? "<3" : flareHeart.getAsMention()));
    }

    if (type != MessageType.WARNING && type != MessageType.ERROR && builder.getFields().isEmpty()) {
        Optional<String> globalMsg = getGlobalMessage();
        if ((!lastGlobalMsg.containsKey(channel.getIdLong())
                || System.currentTimeMillis() - lastGlobalMsg.get(channel.getIdLong()) >= GLOBAL_MSG_DELAY)
                && globalMsg.isPresent()) {
            lastGlobalMsg.put(channel.getIdLong(), System.currentTimeMillis());

            builder.setDescription(builder.build().getDescription() + "\n\n" + globalMsg.get());
        }
    }
    if (autoDeleteDelay > 0)
        sendAutoDeletedMessage(builder.build(), autoDeleteDelay, channel);
    else
        sendMessage(builder.build(), channel);
}
 
Example 4
Source File: EmoteCmd.java    From Selfbot with Apache License 2.0 6 votes vote down vote up
@Override
protected void execute(String args, MessageReceivedEvent event) {
    String id = args.replaceAll("<:.+:(\\d+)>", "$1");
    Emote emote = event.getJDA().getEmoteById(id);
    if(emote==null)
        tempReply("Invalid emote or emote ID", event);
    else
    {
        EmbedBuilder builder = new EmbedBuilder();
        if(event.getGuild()!=null)
            builder.setColor(event.getGuild().getSelfMember().getColor());
        builder.setImage(emote.getImageUrl());
        builder.setDescription(emote.getAsMention()+" **:"+emote.getName()+":**\nID: **"+emote.getId()+"**\nGuild: **"+emote.getGuild().getName()+"**");
        reply(builder.build(), event);
    }
}
 
Example 5
Source File: DonateCommand.java    From FlareBot with MIT License 5 votes vote down vote up
@Override
public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) {
    EmbedBuilder builder = MessageUtils.getEmbed(sender);
    builder.setColor(Color.CYAN);
    builder.setDescription("Thank for you taking the time to see how you can donate to the project! This project relies heavily upon user donations so every little helps! \uD83D\uDE0A");
    builder.addField("Patreon", "The most common way to donate is through our [Patreon page](https://www.patreon.com/flarebot)! Through here you can donate the amount you want and also get rewarded for it!", false);
    builder.addField("PayPal", "If you cannot donate through Patreon or don't like the idea of a monthly subscription then this option is for you! Simply join our [support server](" + Constants.INVITE_URL + ") and our amazing staff will assist you in doing this!\n\nShould you want to donate anonymously or you don't want to receive a reward, you can simply send money to `[email protected]` via PayPal to donate!", false);
    channel.sendMessage(builder.build()).queue();
}
 
Example 6
Source File: StatsCommand.java    From FlareBot with MIT License 5 votes vote down vote up
@Override
public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) {
    if (args.length == 0) {
        EmbedBuilder bld = MessageUtils.getEmbed(sender).setColor(Color.CYAN)
                .setThumbnail(MessageUtils.getAvatar(channel.getJDA().getSelfUser()));
        bld.setDescription("FlareBot v" + FlareBot.instance().getVersion() + " stats");
        for (MultiSelectionContent<String, String, Boolean> content : Content.values) {
            bld.addField(content.getName(), content.getReturn(), content.isAlign());
        }
        channel.sendMessage(bld.build()).queue();
    } else
        GeneralUtils.handleMultiSelectionCommand(sender, channel, args, Content.values);
}
 
Example 7
Source File: PingCommand.java    From DiscordBlueBot with MIT License 5 votes vote down vote up
@Override
public void action(String[] args, MessageReceivedEvent event) {
    EmbedBuilder builder = new EmbedBuilder();
    builder.setColor(Color.decode(MainBot.getConfig().getEmbedColor()));
    builder.setAuthor("I'm online !");
    builder.setDescription("Ping : " + event.getJDA().getPing() + " ms");

    event.getTextChannel().sendMessage(builder.build()).queue();
}
 
Example 8
Source File: EmbedCmd.java    From Selfbot with Apache License 2.0 5 votes vote down vote up
@Override
protected void execute(String args, MessageReceivedEvent event) {
    if(args==null || args.isEmpty())
    {
        reply("Embeds:\n"
                + "`{title:`TEXT`|`URL`}` or `{title:`TEXT`}`\n"
                + "`{author:`NAME`|`IMAGE`|`URL`}` or `{author:`NAME`|`IMAGE`}` or `{author:`NAME`}`\n"
                + "`{thumbnail:`IMAGE`}`\n"
                + "`{field:`NAME`|`VALUE`|`true/false`}` or `{field:`NAME`|`VALUE`}` *can include multiple fields\n"
                + "`{image:`IMAGE`}`\n"
                + "`{color:`#HEX`}` or `{color:name}`\n"
                + "`{footer:`TEXT`|`IMAGE`}` or `{footer:`TEXT`}`\n"
                + "`{timestamp:`ISO`}` or `{timestamp}` *current time if nothing included\n"
                + "Any remaining text goes into the description", event);
        return;
    }
    EmbedBuilder builder = new EmbedBuilder();
    if(event.getGuild()!=null)
        builder.setColor(event.getGuild().getSelfMember().getColor());
    parser.put("builder", builder);
    try {
        String descr = parser.parse(args).trim();
        if(!descr.isEmpty())
            builder.setDescription(descr);
        reply(builder.build(), event);
    } catch(Exception e) {
        reply(Constants.FAILURE+" Error: "+e, event);
    }
}
 
Example 9
Source File: ListCmd.java    From Selfbot with Apache License 2.0 5 votes vote down vote up
@Override
protected void execute(String args, MessageReceivedEvent event) {
    Collection<String> list = emojis.getEmojiList();
    if(list.isEmpty())
    {
        tempReply("No custom emojis!", event);
        return;
    }
    
    EmbedBuilder builder = new EmbedBuilder();
    if(event.getGuild()!=null)
        builder.setColor(event.getGuild().getSelfMember().getColor());
    builder.setAuthor("Custom Emojis:", null, null);
    
    StringBuilder sbuilder = new StringBuilder();
    for(String ename: list)
    {
        String next = "\n`:"+ename+":` \u27A1 `"+emojis.getEmoji(ename)+"`";
        if(sbuilder.length()+next.length()>1985)
        {
            reply(builder.setDescription(sbuilder.toString().trim()).build(),event);
            builder.setAuthor(null,null,null);
            sbuilder = new StringBuilder();
        }
        sbuilder.append(next);
    }
    
    builder.setDescription(sbuilder.toString().trim());
    reply(builder.build(), event);
}
 
Example 10
Source File: MeCmd.java    From Selfbot with Apache License 2.0 5 votes vote down vote up
@Override
protected void execute(String args, MessageReceivedEvent event) {
    EmbedBuilder builder = new EmbedBuilder();
    String username;
    if(event.getGuild()!=null)
    {
        Member member = event.getGuild().getSelfMember();
        builder.setColor(member.getColor());
        username = member.getEffectiveName();
    }
    else
        username = event.getAuthor().getName();
    builder.setDescription("***"+username+"*** *"+args+"*");
    reply(builder.build(), event);
}