diff --git a/packages/core/src/components/discord-embed-field/DiscordEmbedField.ts b/packages/core/src/components/discord-embed-field/DiscordEmbedField.ts index 7e22e855f..6387cafb2 100644 --- a/packages/core/src/components/discord-embed-field/DiscordEmbedField.ts +++ b/packages/core/src/components/discord-embed-field/DiscordEmbedField.ts @@ -132,7 +132,7 @@ export class DiscordEmbedField extends LitElement implements LightTheme { return el.map((wordOrHtmlTemplate) => { if (typeof wordOrHtmlTemplate === 'string') { - return html`
${wordOrHtmlTemplate}
`; + return html`${wordOrHtmlTemplate}`; } return wordOrHtmlTemplate; diff --git a/packages/core/src/components/discord-embed/DiscordEmbed.ts b/packages/core/src/components/discord-embed/DiscordEmbed.ts index 4509bca2e..adcd1566b 100644 --- a/packages/core/src/components/discord-embed/DiscordEmbed.ts +++ b/packages/core/src/components/discord-embed/DiscordEmbed.ts @@ -426,7 +426,7 @@ export class DiscordEmbed extends LitElement implements LightTheme { return el.map((wordOrHtmlTemplate) => { if (typeof wordOrHtmlTemplate === 'string') { - return html`
${wordOrHtmlTemplate}
`; + return html`${wordOrHtmlTemplate}`; } return wordOrHtmlTemplate; diff --git a/packages/core/src/util.ts b/packages/core/src/util.ts index 2edbff917..555b45fab 100644 --- a/packages/core/src/util.ts +++ b/packages/core/src/util.ts @@ -38,4 +38,22 @@ export const validateImageExtension = (url: string) => { throw new DiscordComponentsError(`The url of an image for discord-image-attachment should match the regex ${IMAGE_EXTENSION}`); }; -export const getGlobalEmojiUrl = (emojiName: string): Emoji | undefined => getConfig().emojis?.[emojiName]; +const emojiRegex = /(?:<(?a)?:(?\w{2,32}):)?(?\d{17,21})>?/; +export const getGlobalEmojiUrl = (emojiName: string): Emoji | undefined => { + const globalEmoji = getConfig().emojis?.[emojiName]; + if (globalEmoji) return globalEmoji; + + const match = emojiRegex.exec(emojiName); + + if (match?.groups) { + const { name, id, animated } = match.groups; + const extension = animated ? 'gif' : 'png'; + + return { + name, + url: `https://cdn.discordapp.com/emojis/${id}.${extension}` + }; + } + + return undefined; +};