/** * Adds the provided {@link net.dv8tion.jda.core.entities.MessageEmbed MessageEmbeds} * to this builder. * * <p><b>You can send up to 10 embeds per message! If more are sent they will not be displayed.</b> * * @param embeds * The embeds to add * * @throws java.lang.IllegalArgumentException * If any of the provided embeds is {@code null} * or exceeds the maximum total character count of {@link MessageEmbed#EMBED_MAX_LENGTH_BOT} * * @return The current WebhookMessageBuilder for chaining convenience */ public WebhookMessageBuilder addEmbeds(Collection<MessageEmbed> embeds) { Checks.notNull(embeds, "Embeds"); for (MessageEmbed embed : embeds) { Checks.notNull(embed, "Embed"); Checks.check(embed.isSendable(AccountType.BOT), "One of the provided embeds is empty or exceeds the maximum character count of %d!", MessageEmbed.EMBED_MAX_LENGTH_BOT); this.embeds.add(embed); } return this; }
/** * Adds the provided {@link net.dv8tion.jda.core.entities.MessageEmbed MessageEmbeds} * to this builder. * * <p><b>You can send up to 10 embeds per message! If more are sent they will not be displayed.</b> * * @param embeds * The embeds to add * * @throws java.lang.IllegalArgumentException * If any of the provided embeds is {@code null} * or exceeds the maximum total character count of {@link MessageEmbed#EMBED_MAX_LENGTH_BOT} * * @return The current WebhookMessageBuilder for chaining convenience */ public WebhookMessageBuilder addEmbeds(MessageEmbed... embeds) { Checks.notNull(embeds, "Embeds"); for (MessageEmbed embed : embeds) { Checks.notNull(embed, "Embed"); Checks.check(embed.isSendable(AccountType.BOT), "One of the provided embeds is empty or exceeds the maximum character count of %d!", MessageEmbed.EMBED_MAX_LENGTH_BOT); this.embeds.add(embed); } return this; }
/** * Sets the {@link net.dv8tion.jda.core.entities.MessageEmbed MessageEmbed} * that should be used for this Message. * Refer to {@link net.dv8tion.jda.core.EmbedBuilder EmbedBuilder} for more information. * * @param embed * The {@link net.dv8tion.jda.core.entities.MessageEmbed MessageEmbed} that should * be attached to this message, {@code null} to use no embed. * * @throws java.lang.IllegalArgumentException * If the provided MessageEmbed is not sendable according to * {@link net.dv8tion.jda.core.entities.MessageEmbed#isSendable(net.dv8tion.jda.core.AccountType) MessageEmbed.isSendable(AccountType)}! * If the provided MessageEmbed is an unknown implementation this operation will fail as we are unable to deserialize it. * * @return Updated MessageAction for chaining convenience */ @CheckReturnValue public MessageAction embed(final MessageEmbed embed) { if (embed != null) { final AccountType type = getJDA().getAccountType(); Checks.check(embed.isSendable(type), "Provided Message contains an empty embed or an embed with a length greater than %d characters, which is the max for %s accounts!", type == AccountType.BOT ? MessageEmbed.EMBED_MAX_LENGTH_BOT : MessageEmbed.EMBED_MAX_LENGTH_CLIENT, type); } this.embed = embed; return this; }