Crux v2020-03-17 17:55:51Z 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 Crux.Structs.Emoji.t/0
struct from raw data.
Resolves the id of a Crux.Structs.Emoji.t/0
.
Converts an Crux.Structs.Emoji.t/0
, a Crux.Structs.Reaction.t/0
, or a String.t/0
to its discord identifier format.
Link to this section Types
id_resolvable()
View Source
(since 0.2.1)
id_resolvable() ::
Crux.Structs.Reaction.t()
| Crux.Structs.Emoji.t()
| Crux.Structs.Snowflake.t()
| String.t()
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.
identifier_resolvable()
View Source
(since 0.2.1)
identifier_resolvable() ::
Crux.Structs.Emoji.t() | Crux.Structs.Reaction.t() | String.t()
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.
t()
View Source
(since 0.1.0)
t() :: %Crux.Structs.Emoji{
animated: 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
}
t() :: %Crux.Structs.Emoji{ animated: 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
create(data) View Source (since 0.1.0)
Creates a Crux.Structs.Emoji.t/0
struct from raw data.
Automatically invoked by
Crux.Structs.create/2
.
resolve_id(resolvable)
View Source
(since 0.2.1)
resolve_id(id_resolvable()) :: Crux.Structs.Snowflake.t() | nil
resolve_id(id_resolvable()) :: Crux.Structs.Snowflake.t() | nil
Resolves the id of a 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
to_identifier(identifier)
View Source
(since 0.1.1)
to_identifier(emoji :: identifier_resolvable()) :: String.t()
to_identifier(emoji :: identifier_resolvable()) :: String.t()
Converts an Crux.Structs.Emoji.t/0
, a Crux.Structs.Reaction.t/0
, or a 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"