question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

request: Custom emoji component for messages and embeds

See original GitHub issue

What are your thoughts on a Discord-Emoji component allowing developers to add custom server emojis to their messages?

This component could accept an emojiName and emojiUrl as properties. They would also be inline components which would be embedded in messages or text. Bot developers using custom emojis in their bots would definitely benefit from this feature.

For bot developers using custom emojis in their embed titles, what are your thoughts on including the ability to add custom emojis in embed titles and field names like so?

Discord Custom Emoji Examples

Screen Shot 2021-11-06 at 7 37 35 PM Screen Shot 2021-11-06 at 7 42 46 PM

I’d be more than happy to help implement this if needed!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
favnacommented, Nov 11, 2021

That’s very interesting @YoannMa. I never would’ve thought it could be done like that. Thanks!

1reaction
YoannMacommented, Nov 11, 2021

You don’t need to create a mapping for the Twemoji as you can build the code from the name, I took the algorithm from https://github.com/twitter/twemoji and made my own helper to get the URL out of an emoji object


    /**
     * @param {Emoji|GuildEmoji|ReactionEmoji} emoji
     * @param {Object}                         [options]
     *
     * @return {string}
     */
    static emojiURL(emoji, options = {}) {

        if (emoji.url) {

            return emoji.url;
        }

        const { cdn = 'https://twemoji.maxcdn.com', v = 'latest', sep = '-', size = '72x72', ext = 'png' } = options;

        const surrogates = emoji.name.indexOf(String.fromCharCode(0x200D)) < 0 ? emoji.name.replace(/\uFE0F/g, '') : emoji.name;

        const r = [];

        let c = 0;
        let p = 0;
        let i = 0;

        while (i < surrogates.length) {

            c = surrogates.charCodeAt(i++);

            if (p) {
                r.push((0x10000 + ((p - 0xD800) << 10) + (c - 0xDC00)).toString(16));
                p = 0;
            }
            else if (c >= 0xD800 && c <= 0xDBFF) {
                p = c;
            }
            else {
                r.push(c.toString(16));
            }
        }

        const code = r.join(sep);

        return [cdn, 'v', v, size, `${ code }.${ ext }`].join('/');
    }

I haven’t tested all the different Twemoji, but I tested composed emoji like :woman_factory_worker: without issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to display an custom emoji within a bot message #390
It's <:emoji_name:emoji_id> for custom emojis. You can also find the discord.Emoji instance through Server.emojis and then cast it to str .
Read more >
Discord Bot Embed Custom Emoji - Stack Overflow
It's easiest to get the Emoji object that represents your custom emoji, then use that to build your strings from discord.utils import get ......
Read more >
Reactions - discord.js Guide
To react with an emoji, you need to use the message.react() method. ... For custom emojis, there are multiple ways of reacting.
Read more >
Post Reaction with Emoji with Discord Bot API on New ...
Post Reaction with Emoji with Discord Bot API on New Requests from HTTP / Webhook ... Custom Request with HTTP / Webhook API...
Read more >
EASY Styled Message/Custom Embeds | Discord - YouTube
Looking to create advanced Discord embeds or posts with embedded text, images, previews, links, buttons, dropdown options and more?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found