Class Emoji
A Unicode emoji.
Implements
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
Constructors
| Improve this Doc View SourceEmoji(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 SourceName
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. |
Methods
| Improve this Doc View SourceEquals(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 |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
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: |
Returns
Type | Description |
---|---|
Emoji |
ToString()
Gets the Unicode representation of this emoji.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A string that resolves to Name. |
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:
|
Emoji | result | An emoji. |
Returns
Type | Description |
---|---|
Boolean |
Operators
| Improve this Doc View SourceImplicit(String to Emoji)
Declaration
public static implicit operator Emoji(string s)
Parameters
Type | Name | Description |
---|---|---|
String | s |
Returns
Type | Description |
---|---|
Emoji |