Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EmbedBuilder#setUrl #2449

Merged
merged 2 commits into from
May 2, 2023
Merged
Changes from 1 commit
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
27 changes: 27 additions & 0 deletions src/main/java/net/dv8tion/jda/api/EmbedBuilder.java
Original file line number Diff line number Diff line change
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,32 @@ 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.
Xirado marked this conversation as resolved.
Show resolved Hide resolved
*
* @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