From 76de8c424e13c60d63d78894c1894a0ab2390e81 Mon Sep 17 00:00:00 2001 From: Lualt <58912038+LualtOfficial@users.noreply.github.com> Date: Tue, 27 Feb 2024 13:27:37 +0100 Subject: [PATCH] feat(plugin) FakeNitro: Allow customising hyperlink text (#2192) Co-authored-by: Vendicated --- src/plugins/fakeNitro/index.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index b9932d291..20125c7d1 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -161,6 +161,11 @@ const settings = definePluginSettings({ type: OptionType.BOOLEAN, default: true }, + hyperLinkText: { + description: "What text the hyperlink should use. {{NAME}} will be replaced with the emoji name.", + type: OptionType.STRING, + default: "{{NAME}}" + } }).withPrivateSettings<{ disableEmbedPermissionCheck: boolean; }>(); @@ -880,8 +885,10 @@ export default definePlugin({ url.searchParams.set("size", s.emojiSize.toString()); url.searchParams.set("name", emoji.name); + const linkText = s.hyperLinkText.replaceAll("{{NAME}}", emoji.name); + messageObj.content = messageObj.content.replace(emojiString, (match, offset, origStr) => { - return `${getWordBoundary(origStr, offset - 1)}${s.useHyperLinks ? `[${emoji.name}](${url})` : url}${getWordBoundary(origStr, offset + match.length)}`; + return `${getWordBoundary(origStr, offset - 1)}${s.useHyperLinks ? `[${linkText}](${url})` : url}${getWordBoundary(origStr, offset + match.length)}`; }); } } @@ -917,7 +924,9 @@ export default definePlugin({ url.searchParams.set("size", s.emojiSize.toString()); url.searchParams.set("name", emoji.name); - return `${getWordBoundary(origStr, offset - 1)}${s.useHyperLinks ? `[${emoji.name}](${url})` : url}${getWordBoundary(origStr, offset + emojiStr.length)}`; + const linkText = s.hyperLinkText.replaceAll("{{NAME}}", emoji.name); + + return `${getWordBoundary(origStr, offset - 1)}${s.useHyperLinks ? `[${linkText}](${url})` : url}${getWordBoundary(origStr, offset + emojiStr.length)}`; }); if (hasBypass && !s.disableEmbedPermissionCheck && !hasEmbedPerms(channelId)) {