From c1532ba6ec3e21b5e5f03488f34933b8296004ad Mon Sep 17 00:00:00 2001 From: Matyrobbrt Date: Tue, 24 Sep 2024 12:09:58 +0300 Subject: [PATCH] Allow setting only the URL of an embed --- .../java/net/neoforged/camelot/script/ScriptMap.java | 9 ++++++++- trickTypes.d.ts | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/neoforged/camelot/script/ScriptMap.java b/src/main/java/net/neoforged/camelot/script/ScriptMap.java index 05dd2dd..697b6b2 100644 --- a/src/main/java/net/neoforged/camelot/script/ScriptMap.java +++ b/src/main/java/net/neoforged/camelot/script/ScriptMap.java @@ -83,7 +83,14 @@ public MessageEmbed asEmbed() { final EmbedBuilder builder = new EmbedBuilder(); builder.setDescription(getString("description")); - stringOrObject("title", builder::setTitle, obj -> builder.setTitle(obj.getString("value"), obj.getString("url"))); + stringOrObject("title", builder::setTitle, obj -> { + var title = obj.getString("value"); + if (title == null || title.isBlank()) { + builder.setUrl(obj.getString("url")); + } else { + builder.setTitle(title, obj.getString("url")); + } + }); getList("fields").stream().map(ScriptMap::new).forEach(field -> builder.addField( Objects.requireNonNull(field.getString("name")), diff --git a/trickTypes.d.ts b/trickTypes.d.ts index b6b7429..9eee5ee 100644 --- a/trickTypes.d.ts +++ b/trickTypes.d.ts @@ -119,13 +119,13 @@ export interface Privileged { declare namespace Embeds { export type Title = { - value: string | null; - url: string | null; + value?: string | null; + url?: string | null; } export type Footer = { - value: string | null, - iconUrl: string | null + value?: string | null, + iconUrl?: string | null } export type Field = {