Table of Contents

Emoji in Discord.Net

Before we delve into the difference between an Emoji and an Emote in Discord.Net, it is crucial to understand what they both look like behind the scene. When the end-users are sending or receiving an emoji or emote, they are typically in the form of :ok_hand: or :reeee:; however, what goes under the hood is that, depending on the type of emoji, they are sent in an entirely different format.

What does this all mean? It means that you should know that by reacting with a string like “:ok_hand:” will NOT automatically translate to 👌; rather, it will be treated as-is, like :ok_hand:, thus the server will return a 400 Bad Request.

Emoji

An emoji is a standard emoji that can be found anywhere else outside of Discord, which means strings like 👌, , 👀 are all considered an emoji in Discord. However, from the introduction paragraph we have learned that we cannot simply send :ok_hand: and have Discord take care of it, but what do we need to send exactly?

To send an emoji correctly, one must send the emoji in its Unicode form; this can be obtained in several different ways.

  1. (Easiest) Escape the emoji by using the escape character, \, in your Discord chat client; this will reveal the emoji’s pure Unicode form, which will allow you to copy-paste into your code.
  2. Look it up on Emojipedia, from which you can copy the emoji easily into your code. Emojipedia
  3. (Recommended) Look it up in the Emoji list from FileFormat.Info; this will give you the .NET-compatible code that represents the emoji.
    • This is the most recommended method because some systems or IDE sometimes do not render the Unicode emoji correctly. Fileformat Emoji Source Code

Emoji Declaration

After obtaining the Unicode representation of the emoji, you may create the Emoji object by passing the string with unicode into its constructor (e.g. new Emoji("👌"); or new Emoji("\uD83D\uDC4C");).

Your method of declaring an Emoji should look similar to this:

public async Task ReactAsync(SocketUserMessage userMsg)
{
    // equivalent to "👌"
    var emoji = new Emoji("\uD83D\uDC4C");
    await userMsg.AddReactionAsync(emoji);
}

Also you can use Emoji.Parse() or Emoji.TryParse() methods for parsing emojis from strings like :heart:, <3 or .

Emote

The meat of the debate is here; what is an emote and how does it differ from an emoji? An emote refers to a custom emoji created on Discord.

The underlying structure of an emote also differs drastically; an emote looks sort-of like a mention on Discord. It consists of two main elements as illustrated below:

Emote illustration

As you can see, emote uses a completely different format. To obtain the raw string as shown above for your emote, you would need to escape the emote using the escape character \ in chat somewhere.

Emote Declaration

After obtaining the raw emote string, you would need to use Parse or TryParse to create a valid emote object.

Your method of declaring an Emote should look similar to this:

public async Task ReactWithEmoteAsync(SocketUserMessage userMsg, string escapedEmote)
{
    if (Emote.TryParse(escapedEmote, out var emote))
    {
        await userMsg.AddReactionAsync(emote);
    }
}
Tip

For WebSocket users, you may also consider fetching the Emote via the Emotes collection.

private readonly DiscordSocketClient _client;

public async Task ReactAsync(SocketUserMessage userMsg, string emoteName)
{
    var emote = _client.Guilds
            .SelectMany(x => x.Emotes)
            .FirstOrDefault(x => x.Name.IndexOf(
                emoteName, StringComparison.OrdinalIgnoreCase) != -1);
    if (emote == null) return;
    await userMsg.AddReactionAsync(emote);
}
Tip

On Discord, any user with Discord Nitro subscription may use custom emotes from any guilds they are currently in. This is also true for any standard bot accounts; this does not require the bot owner to have a Nitro subscription.

Additional Information

To learn more about emote and emojis and how they could be used, see the documentation of IEmote.