Skip to content

Commit

Permalink
Add EmbedBuilder#setUrl (#2449)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xirado committed May 2, 2023
1 parent ce27c30 commit 6c28f61
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/main/java/net/dv8tion/jda/api/EmbedBuilder.java
Expand Up @@ -261,6 +261,7 @@ public EmbedBuilder setTitle(@Nullable String title)
/**
* Sets the Title of the embed.
* <br>You can provide {@code null} as url if no url should be used.
* <br>If you want to set a URL without a title, use {@link #setUrl(String)} instead.
*
* <p><b><a href="https://raw.githubusercontent.com/DV8FromTheWorld/JDA/assets/assets/docs/embeds/04-setTitle.png">Example</a></b>
*
Expand Down Expand Up @@ -303,6 +304,34 @@ public EmbedBuilder setTitle(@Nullable String title, @Nullable String url)
return this;
}

/**
* Sets the URL of the embed.
* <br>The Discord client mostly only uses this property in combination with the {@link #setTitle(String) title} for a clickable Hyperlink.
*
* <p>If multiple embeds in a message use the same URL, the Discord client will merge them into a single embed and aggregate images into a gallery view.
*
* @throws java.lang.IllegalArgumentException
* <ul>
* <li>If the character limit for {@code url}, defined by {@link net.dv8tion.jda.api.entities.MessageEmbed#URL_MAX_LENGTH} as {@value net.dv8tion.jda.api.entities.MessageEmbed#URL_MAX_LENGTH},
* is exceeded.</li>
* <li>If the provided {@code url} is not a properly formatted http or https url.</li>
* </ul>
*
* @return the builder after the URL has been set
*
* @see #setTitle(String, String)
*/
@Nonnull
public EmbedBuilder setUrl(@Nullable String url)
{
if (Helpers.isBlank(url))
url = null;
urlCheck(url);
this.url = url;

return this;
}

/**
* The {@link java.lang.StringBuilder StringBuilder} used to
* build the description for the embed.
Expand Down

0 comments on commit 6c28f61

Please sign in to comment.