Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ default Button withEmoji(@Nullable Emoji emoji)
* @throws IllegalArgumentException
* <ul>
* <li>If this is a {@link ButtonStyle#PREMIUM PREMIUM}-styled button</li>
* <li>If the provided {@code label} is null or empty.</li>
* <li>If the provided {@code label} is null or blank.</li>
* <li>If the character limit for {@code label}, defined by {@link #LABEL_MAX_LENGTH} as {@value #LABEL_MAX_LENGTH},
* is exceeded.</li>
* </ul>
Expand Down Expand Up @@ -306,7 +306,7 @@ default Button withStyle(@Nonnull ButtonStyle style)
*
* @throws IllegalArgumentException
* <ul>
* <li>If any provided argument is null or empty.</li>
* <li>If any provided argument is null or blank.</li>
* <li>If the character limit for {@code id}, defined by {@link #ID_MAX_LENGTH} as {@value #ID_MAX_LENGTH},
* is exceeded.</li>
* <li>If the character limit for {@code label}, defined by {@link #LABEL_MAX_LENGTH} as {@value #LABEL_MAX_LENGTH},
Expand Down Expand Up @@ -335,7 +335,7 @@ static Button primary(@Nonnull String id, @Nonnull String label)
*
* @throws IllegalArgumentException
* <ul>
* <li>If any provided argument is null or empty.</li>
* <li>If any provided argument is null or blank.</li>
* <li>If the character limit for {@code id}, defined by {@link #ID_MAX_LENGTH} as {@value #ID_MAX_LENGTH},
* is exceeded.</li>
* </ul>
Expand All @@ -360,7 +360,7 @@ static Button primary(@Nonnull String id, @Nonnull Emoji emoji)
*
* @throws IllegalArgumentException
* <ul>
* <li>If any provided argument is null or empty.</li>
* <li>If any provided argument is null or blank.</li>
* <li>If the character limit for {@code id}, defined by {@link #ID_MAX_LENGTH} as {@value #ID_MAX_LENGTH},
* is exceeded.</li>
* <li>If the character limit for {@code label}, defined by {@link #LABEL_MAX_LENGTH} as {@value #LABEL_MAX_LENGTH},
Expand Down Expand Up @@ -389,7 +389,7 @@ static Button secondary(@Nonnull String id, @Nonnull String label)
*
* @throws IllegalArgumentException
* <ul>
* <li>If any provided argument is null or empty.</li>
* <li>If any provided argument is null or blank.</li>
* <li>If the character limit for {@code id}, defined by {@link #ID_MAX_LENGTH} as {@value #ID_MAX_LENGTH},
* is exceeded.</li>
* </ul>
Expand All @@ -414,7 +414,7 @@ static Button secondary(@Nonnull String id, @Nonnull Emoji emoji)
*
* @throws IllegalArgumentException
* <ul>
* <li>If any provided argument is null or empty.</li>
* <li>If any provided argument is null or blank.</li>
* <li>If the character limit for {@code id}, defined by {@link #ID_MAX_LENGTH} as {@value #ID_MAX_LENGTH},
* is exceeded.</li>
* <li>If the character limit for {@code label}, defined by {@link #LABEL_MAX_LENGTH} as {@value #LABEL_MAX_LENGTH},
Expand Down Expand Up @@ -443,7 +443,7 @@ static Button success(@Nonnull String id, @Nonnull String label)
*
* @throws IllegalArgumentException
* <ul>
* <li>If any provided argument is null or empty.</li>
* <li>If any provided argument is null or blank.</li>
* <li>If the character limit for {@code id}, defined by {@link #ID_MAX_LENGTH} as {@value #ID_MAX_LENGTH},
* is exceeded.</li>
* </ul>
Expand All @@ -468,7 +468,7 @@ static Button success(@Nonnull String id, @Nonnull Emoji emoji)
*
* @throws IllegalArgumentException
* <ul>
* <li>If any provided argument is null or empty.</li>
* <li>If any provided argument is null or blank.</li>
* <li>If the character limit for {@code id}, defined by {@link #ID_MAX_LENGTH} as {@value #ID_MAX_LENGTH},
* is exceeded.</li>
* <li>If the character limit for {@code label}, defined by {@link #LABEL_MAX_LENGTH} as {@value #LABEL_MAX_LENGTH},
Expand Down Expand Up @@ -497,7 +497,7 @@ static Button danger(@Nonnull String id, @Nonnull String label)
*
* @throws IllegalArgumentException
* <ul>
* <li>If any provided argument is null or empty.</li>
* <li>If any provided argument is null or blank.</li>
* <li>If the character limit for {@code id}, defined by {@link #ID_MAX_LENGTH} as {@value #ID_MAX_LENGTH},
* is exceeded.</li>
* </ul>
Expand Down Expand Up @@ -525,7 +525,7 @@ static Button danger(@Nonnull String id, @Nonnull Emoji emoji)
*
* @throws IllegalArgumentException
* <ul>
* <li>If any provided argument is null or empty.</li>
* <li>If any provided argument is null or blank.</li>
* <li>If the character limit for {@code url}, defined by {@link #URL_MAX_LENGTH} as {@value #URL_MAX_LENGTH},
* is exceeded.</li>
* <li>If the character limit for {@code label}, defined by {@link #LABEL_MAX_LENGTH} as {@value #LABEL_MAX_LENGTH},
Expand Down Expand Up @@ -557,7 +557,7 @@ static Button link(@Nonnull String url, @Nonnull String label)
*
* @throws IllegalArgumentException
* <ul>
* <li>If any provided argument is null or empty.</li>
* <li>If any provided argument is null or blank.</li>
* <li>If the character limit for {@code url}, defined by {@link #URL_MAX_LENGTH} as {@value #URL_MAX_LENGTH},
* is exceeded.</li>
* </ul>
Expand Down Expand Up @@ -610,7 +610,7 @@ static Button premium(@Nonnull SkuSnowflake sku)
*
* @throws IllegalArgumentException
* <ul>
* <li>If any provided argument is null or empty.</li>
* <li>If any provided argument is null or blank.</li>
* <li>If the requested style is {@link ButtonStyle#PREMIUM PREMIUM}.</li>
* <li>If the id is longer than {@value #ID_MAX_LENGTH}, as defined by {@link #ID_MAX_LENGTH}.</li>
* <li>If the url is longer than {@value #URL_MAX_LENGTH}, as defined by {@link #URL_MAX_LENGTH}.</li>
Expand Down Expand Up @@ -647,7 +647,7 @@ static Button of(@Nonnull ButtonStyle style, @Nonnull String idOrUrl, @Nonnull S
*
* @throws IllegalArgumentException
* <ul>
* <li>If any provided argument is null or empty.</li>
* <li>If any provided argument is null or blank.</li>
* <li>If the requested style is {@link ButtonStyle#PREMIUM PREMIUM}.</li>
* <li>If the id is longer than {@value #ID_MAX_LENGTH}, as defined by {@link #ID_MAX_LENGTH}.</li>
* <li>If the url is longer than {@value #URL_MAX_LENGTH}, as defined by {@link #URL_MAX_LENGTH}.</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.dv8tion.jda.internal.entities.EntityBuilder;
import net.dv8tion.jda.internal.utils.Checks;
import net.dv8tion.jda.internal.utils.EntityString;
import net.dv8tion.jda.internal.utils.Helpers;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -82,16 +83,16 @@ public ButtonImpl checkValid()
case DANGER:
Checks.check(url == null, "Cannot set an URL on action buttons");
Checks.check(sku == null, "Cannot set an SKU on action buttons");
Checks.check(emoji != null || !label.isEmpty(), "Action buttons must have either an emoji or label");
Checks.notEmpty(id, "Id");
Checks.check(emoji != null || !Helpers.isBlank(label), "Action buttons must have either an emoji or label");
Checks.notBlank(id, "Id");
Checks.notLonger(id, ID_MAX_LENGTH, "Id");
break;
case LINK:
Checks.check(id == null, "Cannot set an ID on link buttons");
Checks.check(url != null, "You must set an URL on link buttons");
Checks.check(sku == null, "Cannot set an SKU on link buttons");
Checks.check(emoji != null || !label.isEmpty(), "Link buttons must have either an emoji or label");
Checks.notEmpty(url, "URL");
Checks.check(emoji != null || !Helpers.isBlank(label), "Link buttons must have either an emoji or label");
Checks.notBlank(url, "URL");
Checks.notLonger(url, URL_MAX_LENGTH, "URL");
break;
case PREMIUM:
Expand Down Expand Up @@ -167,7 +168,7 @@ public DataObject toData()
{
DataObject json = DataObject.empty();
json.put("type", 2);
if (!label.isEmpty())
if (!Helpers.isBlank(label))
json.put("label", label);
json.put("style", style.getKey());
json.put("disabled", disabled);
Expand Down