crux_structs v0.2.0 Crux.Structs.Emoji View Source
Represents a Discord Emoji Object.
Differences opposed to the Discord API Object:
:user
is just the user id
Link to this section Summary
Functions
Creates a Crux.Structs.Emoji
struct from raw data
Converts an Crux.Structs.Emoji
, a Crux.Structs.Reaction
, or a String.t()
to its discord identifier format
Link to this section Types
Link to this type
t() View Source (since 0.1.0)
Link to this section Functions
Link to this function
create(data) View Source (since 0.1.0)
Creates a Crux.Structs.Emoji
struct from raw data.
Automatically invoked by
Crux.Structs.create/2
.
Link to this function
to_identifier(identifier)
View Source
(since 0.1.1)
to_identifier(identifier)
View Source
(since 0.1.1)
to_identifier(
emoji :: Crux.Structs.Emoji.t() | Crux.Structs.Reaction.t() | String.t()
) :: String.t()
to_identifier( emoji :: Crux.Structs.Emoji.t() | Crux.Structs.Reaction.t() | String.t() ) :: String.t()
Converts an Crux.Structs.Emoji
, a Crux.Structs.Reaction
, or a String.t()
to its discord identifier format.
> This is automatically done if using a appropriate rest function.
Examples
# A custom emoji
iex> %Crux.Structs.Emoji{animated: false, id: 396521773216301056, name: "blobwavereverse"}
...> |> Crux.Structs.Emoji.to_identifier()
"blobwavereverse:396521773216301056"
# A custom animated emoji
iex> %Crux.Structs.Emoji{animated: true, id: 396521774466203659, name: "ablobwavereverse"}
...> |> Crux.Structs.Emoji.to_identifier()
"a:ablobwavereverse:396521774466203659"
# A regular emoji
iex> %Crux.Structs.Emoji{animated: false, id: nil, name: "👋"}
...> |> Crux.Structs.Emoji.to_identifier()
"%F0%9F%91%8B"
# A reaction struct
iex> %Crux.Structs.Reaction{
...> emoji: %Crux.Structs.Emoji{animated: false, id: 356830260626456586, name: "blobReach"}
...> }
...> |> Crux.Structs.Emoji.to_identifier()
"blobReach:356830260626456586"
# An already encoded identifier
iex> "👀" |> URI.encode_www_form()
...> |> Crux.Structs.Emoji.to_identifier()
"%F0%9F%91%80"
# A custom emoji's identifier
iex> "eyesRight:271412698267254784"
...> |> Crux.Structs.Emoji.to_identifier()
"eyesRight:271412698267254784"