crux_structs v0.2.3 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
Types
All available types that can be resolved into an emoji id.
All available types that can be resolved into a discord emoji identifier.
Functions
Creates a t:Crux.Structs.Emoji.t/0
struct from raw data.
Resolves the id of a t:Crux.Structs.Emoji.t/0
.
Converts an t:Crux.Structs.Emoji.t/0
, a t:Crux.Structs.Reaction.t/0
, or a t:String.t/0
to its discord identifier format.
Link to this section Types
Specs
id_resolvable() :: Crux.Structs.Reaction.t() | Crux.Structs.Emoji.t() | Crux.Structs.Snowflake.t() | String.t()
All available types that can be resolved into an emoji id.
Specs
identifier_resolvable() :: Crux.Structs.Emoji.t() | Crux.Structs.Reaction.t() | String.t()
All available types that can be resolved into a discord emoji identifier.
String.t() stands for an already encoded unicode emoji.
Specs
t() :: %Crux.Structs.Emoji{ animated: boolean() | nil, available: boolean() | nil, id: Crux.Structs.Snowflake.t() | nil, managed: boolean() | nil, name: String.t(), require_colons: boolean() | nil, roles: MapSet.t(Crux.Structs.Snowflake.t()), user: Crux.Structs.Snowflake.t() | nil }
Link to this section Functions
Specs
Creates a t:Crux.Structs.Emoji.t/0
struct from raw data.
Automatically invoked by
Crux.Structs.create/2
.
Specs
resolve_id(id_resolvable()) :: Crux.Structs.Snowflake.t() | nil
Resolves the id of a t:Crux.Structs.Emoji.t/0
.
Automatically invoked by
Crux.Structs.resolve_id/2
.
iex> %Crux.Structs.Emoji{id: 618731477143912448}
...> |> Crux.Structs.Emoji.resolve_id()
618731477143912448
iex> %Crux.Structs.Reaction{emoji: %Crux.Structs.Emoji{id: 618731477143912448}}
...> |> Crux.Structs.Emoji.resolve_id()
618731477143912448
iex> 618731477143912448
...> |> Crux.Structs.Emoji.resolve_id()
618731477143912448
iex> "618731477143912448"
...> |> Crux.Structs.Emoji.resolve_id()
618731477143912448
Specs
to_identifier(emoji :: identifier_resolvable()) :: String.t()
Converts an t:Crux.Structs.Emoji.t/0
, a t:Crux.Structs.Reaction.t/0
, or a t:String.t/0
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"