diff --git a/src/main/java/net/dv8tion/jda/api/EmbedBuilder.java b/src/main/java/net/dv8tion/jda/api/EmbedBuilder.java index 16b83d98c8..7943e975f2 100644 --- a/src/main/java/net/dv8tion/jda/api/EmbedBuilder.java +++ b/src/main/java/net/dv8tion/jda/api/EmbedBuilder.java @@ -155,7 +155,15 @@ public static EmbedBuilder fromData(@Nonnull DataObject data) * that has been checked as being valid for sending. * * @throws java.lang.IllegalStateException - * If the embed is empty. Can be checked with {@link #isEmpty()}. + * * * @return the built, sendable {@link net.dv8tion.jda.api.entities.MessageEmbed} */ @@ -167,7 +175,9 @@ public MessageEmbed build() if (description.length() > MessageEmbed.DESCRIPTION_MAX_LENGTH) throw new IllegalStateException(Helpers.format("Description is longer than %d! Please limit your input!", MessageEmbed.DESCRIPTION_MAX_LENGTH)); if (length() > MessageEmbed.EMBED_MAX_LENGTH_BOT) - throw new IllegalStateException("Cannot build an embed with more than " + MessageEmbed.EMBED_MAX_LENGTH_BOT + " characters!"); + throw new IllegalStateException(Helpers.format("Cannot build an embed with more than %d characters!", MessageEmbed.EMBED_MAX_LENGTH_BOT)); + if (fields.size() > MessageEmbed.MAX_FIELD_AMOUNT) + throw new IllegalStateException(Helpers.format("Cannot build an embed with more than %d embed fields set!", MessageEmbed.MAX_FIELD_AMOUNT)); final String description = this.description.length() < 1 ? null : this.description.toString(); return EntityBuilder.createMessageEmbed(url, title, description, EmbedType.RICH, timestamp, diff --git a/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java b/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java index b54a270965..d677147059 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java +++ b/src/main/java/net/dv8tion/jda/api/entities/MessageEmbed.java @@ -115,6 +115,13 @@ public class MessageEmbed implements SerializableData @ForRemoval public static final int EMBED_MAX_LENGTH_CLIENT = 2000; + /** + * The maximum amount of total embed fields the embed can hold + * + * @see net.dv8tion.jda.api.EmbedBuilder#addField(String, String, boolean) + */ + public static final int MAX_FIELD_AMOUNT = 25; + protected final Object mutex = new Object(); protected final String url;