Search Results for

    Show / Hide Table of Contents

    Class Emoji

    A Unicode emoji.

    Inheritance
    Object
    Emoji
    Implements
    IEmote
    Namespace: Discord
    Assembly: Discord.Net.Core.dll
    Syntax
    public class Emoji : object, IEmote
    Remarks
    Note

    A valid Emoji format is Unicode-based. This means only something like 🙃 or \U0001f643 would work, instead of :upside_down:.

    A Unicode-based emoji can be obtained by escaping with a \ in front of the emote using the Discord chat client or by looking up on Emojipedia.

    This class represents a standard Unicode-based emoji. This type of emoji can be created by passing the Unicode into the constructor.

    Examples

    The sample below sends a message and adds an Emoji and a custom Emote to the message.

    public async Task SendAndReactAsync(ISocketMessageChannel channel)
    {
        var message = await channel.SendMessageAsync("I am a message.");
    
        // Creates a Unicode-based emoji based on the Unicode string.
        // This is effectively the same as new Emoji("💕").
        var heartEmoji = new Emoji("\U0001f495");
        // Reacts to the message with the Emoji.
        await message.AddReactionAsync(heartEmoji);
    
        // Parses a custom emote based on the provided Discord emote format.
        // Please note that this does not guarantee the existence of
        // the emote.
        var emote = Emote.Parse("<:thonkang:282745590985523200>");
        // Reacts to the message with the Emote.
        await message.AddReactionAsync(emote);
    }
    

    Result

    React Example

    Constructors

    | Improve this Doc View Source

    Emoji(String)

    Initializes a new Emoji class with the provided Unicode.

    Declaration
    public Emoji(string unicode)
    Parameters
    Type Name Description
    String unicode

    The pure UTF-8 encoding of an emoji.

    Properties

    | Improve this Doc View Source

    Name

    Gets the display name or Unicode representation of this emote.

    Declaration
    public string Name { get; }
    Property Value
    Type Description
    String

    A string representing the display name or the Unicode representation (e.g. 🤔) of this emote.

    Methods

    | Improve this Doc View Source

    Equals(Object)

    Determines whether the specified emoji is equal to the current one.

    Declaration
    public override bool Equals(object other)
    Parameters
    Type Name Description
    Object other

    The object to compare with the current object.

    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32
    | Improve this Doc View Source

    Parse(String)

    Parse an Emoji from its raw format.

    Declaration
    public static Emoji Parse(string emojiStr)
    Parameters
    Type Name Description
    String emojiStr

    The raw encoding of an emoji. For example: ❤️ or ❤

    Returns
    Type Description
    Emoji
    | Improve this Doc View Source

    ToString()

    Gets the Unicode representation of this emoji.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    A string that resolves to Name.

    | Improve this Doc View Source

    TryParse(String, out Emoji)

    Tries to parse an Emoji from its raw format.

    Declaration
    public static bool TryParse(string text, out Emoji result)
    Parameters
    Type Name Description
    String text

    The raw encoding of an emoji. For example:

    :heart: or ❤

    Emoji result

    An emoji.

    Returns
    Type Description
    Boolean

    Operators

    | Improve this Doc View Source

    Implicit(String to Emoji)

    Declaration
    public static implicit operator Emoji(string s)
    Parameters
    Type Name Description
    String s
    Returns
    Type Description
    Emoji

    Implements

    IEmote

    See Also

    Emoji

    Theme

    • Improve this Doc
    • View Source
    In This Article
    Back to top Discord.Net (c) 2015-2023 3.12.0