From 6c28f61c81842f6c99af3b1679521925602bf878 Mon Sep 17 00:00:00 2001 From: Xirado Date: Tue, 2 May 2023 13:02:22 +0200 Subject: [PATCH] Add EmbedBuilder#setUrl (#2449) --- .../net/dv8tion/jda/api/EmbedBuilder.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/main/java/net/dv8tion/jda/api/EmbedBuilder.java b/src/main/java/net/dv8tion/jda/api/EmbedBuilder.java index ffd1d904b2..46638c1304 100644 --- a/src/main/java/net/dv8tion/jda/api/EmbedBuilder.java +++ b/src/main/java/net/dv8tion/jda/api/EmbedBuilder.java @@ -261,6 +261,7 @@ public EmbedBuilder setTitle(@Nullable String title) /** * Sets the Title of the embed. *
You can provide {@code null} as url if no url should be used. + *
If you want to set a URL without a title, use {@link #setUrl(String)} instead. * *

Example * @@ -303,6 +304,34 @@ public EmbedBuilder setTitle(@Nullable String title, @Nullable String url) return this; } + /** + * Sets the URL of the embed. + *
The Discord client mostly only uses this property in combination with the {@link #setTitle(String) title} for a clickable Hyperlink. + * + *

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 + *

+ * + * @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.