Represents a Discord emoji (unicode or custom guild emoji).
Unicode emojis have only a name (the unicode character).
Custom emojis have an id, name, and optional metadata.
Implements String.Chars so you can interpolate an emoji directly
into a message string and get the correct mention format.
Summary
Functions
Returns the API-formatted string for use in REST endpoints.
Returns true if this is a custom emoji (has an id).
Converts a raw Discord emoji map into this struct.
Returns the CDN URL for a custom emoji image.
Returns the mention string for embedding in messages.
Returns true if this is a unicode emoji (no id).
Types
Functions
Returns the API-formatted string for use in REST endpoints.
Unicode emojis return just the name. Custom emojis return name:id.
Examples
iex> EDA.Emoji.api_name(%EDA.Emoji{id: nil, name: "👍"})
"👍"
iex> EDA.Emoji.api_name(%EDA.Emoji{id: "123", name: "cool"})
"cool:123"
Returns true if this is a custom emoji (has an id).
Examples
iex> EDA.Emoji.custom?(%EDA.Emoji{id: "123", name: "cool"})
true
iex> EDA.Emoji.custom?(%EDA.Emoji{id: nil, name: "👍"})
false
Converts a raw Discord emoji map into this struct.
Examples
iex> EDA.Emoji.from_raw(%{"id" => "123", "name" => "cool", "animated" => true})
%EDA.Emoji{id: "123", name: "cool", animated: true}
iex> EDA.Emoji.from_raw(%{"id" => nil, "name" => "👍"})
%EDA.Emoji{id: nil, name: "👍"}
Returns the CDN URL for a custom emoji image.
Returns nil for unicode emojis.
Animated emojis get a .gif extension, others get .png.
Examples
iex> EDA.Emoji.image_url(%EDA.Emoji{id: "123", name: "cool", animated: true})
"https://cdn.discordapp.com/emojis/123.gif"
iex> EDA.Emoji.image_url(%EDA.Emoji{id: "123", name: "cool"})
"https://cdn.discordapp.com/emojis/123.png"
iex> EDA.Emoji.image_url(%EDA.Emoji{id: nil, name: "👍"})
nil
Returns the mention string for embedding in messages.
Unicode emojis return just the name. Custom emojis return <:name:id>
or <a:name:id> for animated emojis.
Examples
iex> EDA.Emoji.mention(%EDA.Emoji{id: nil, name: "👍"})
"👍"
iex> EDA.Emoji.mention(%EDA.Emoji{id: "123", name: "cool", animated: false})
"<:cool:123>"
iex> EDA.Emoji.mention(%EDA.Emoji{id: "123", name: "cool", animated: true})
"<a:cool:123>"
Returns true if this is a unicode emoji (no id).
Examples
iex> EDA.Emoji.unicode?(%EDA.Emoji{id: nil, name: "👍"})
true
iex> EDA.Emoji.unicode?(%EDA.Emoji{id: "123", name: "cool"})
false