Crux v2020-03-17 17:55:51Z Crux.Structs.Role View Source
Represents a Discord Role Object.
Link to this section Summary
Types
All available types that can be resolved into a role id.
All available types that can be resolved into a role position.
Functions
Creates a Crux.Structs.Role.t/0
struct from raw data.
Resolves a position_resolvable/0
into a role position.
Converts a Crux.Structs.Role.t/0
into its discord mention format.
Link to this section Types
Link to this type
id_resolvable()
View Source
(since 0.2.1)
id_resolvable()
View Source
(since 0.2.1)
id_resolvable() ::
Crux.Structs.Role.t() | Crux.Structs.Snowflake.t() | String.t() | nil
id_resolvable() :: Crux.Structs.Role.t() | Crux.Structs.Snowflake.t() | String.t() | nil
All available types that can be resolved into a role id.
Link to this type
position_resolvable()
View Source
(since 0.2.1)
position_resolvable()
View Source
(since 0.2.1)
position_resolvable() ::
Crux.Structs.Role.t()
| %{role: id_resolvable(), position: integer()}
| {id_resolvable(), integer()}
| %{id: id_resolvable(), position: integer()}
position_resolvable() :: Crux.Structs.Role.t() | %{role: id_resolvable(), position: integer()} | {id_resolvable(), integer()} | %{id: id_resolvable(), position: integer()}
All available types that can be resolved into a role position.
Link to this type
t()
View Source
(since 0.1.0)
t()
View Source
(since 0.1.0)
t() :: %Crux.Structs.Role{
color: integer(),
guild_id: Crux.Structs.Snowflake.t(),
hoist: boolean(),
id: Crux.Structs.Snowflake.t(),
managed: boolean(),
mentionable: boolean(),
name: String.t(),
permissions: integer(),
position: integer()
}
t() :: %Crux.Structs.Role{ color: integer(), guild_id: Crux.Structs.Snowflake.t(), hoist: boolean(), id: Crux.Structs.Snowflake.t(), managed: boolean(), mentionable: boolean(), name: String.t(), permissions: integer(), position: integer() }
Link to this section Functions
Link to this function
create(data) View Source (since 0.1.0)
Creates a Crux.Structs.Role.t/0
struct from raw data.
Automatically invoked by
Crux.Structs.create/2
.
Link to this function
resolve_position(resolvable)
View Source
(since 0.2.1)
resolve_position(resolvable)
View Source
(since 0.2.1)
resolve_position(position_resolvable()) ::
%{id: Crux.Structs.Snowflake.t(), position: integer()} | nil
resolve_position(position_resolvable()) :: %{id: Crux.Structs.Snowflake.t(), position: integer()} | nil
Resolves a position_resolvable/0
into a role position.
Examples
iex> {%Crux.Structs.Role{id: 373405430589816834}, 5}
...> |> Crux.Structs.Role.resolve_position()
%{id: 373405430589816834, position: 5}
iex> %{id: 373405430589816834, position: 5}
...> |> Crux.Structs.Role.resolve_position()
%{id: 373405430589816834, position: 5}
iex> %{role: %Crux.Structs.Role{id: 373405430589816834}, position: 5}
...> |> Crux.Structs.Role.resolve_position()
%{id: 373405430589816834, position: 5}
iex> {373405430589816834, 5}
...> |> Crux.Structs.Role.resolve_position()
%{id: 373405430589816834, position: 5}
iex> {nil, 5}
...> |> Crux.Structs.Role.resolve_position()
nil
Link to this function
to_mention(role)
View Source
(since 0.1.1)
to_mention(role)
View Source
(since 0.1.1)
to_mention(user :: Crux.Structs.Role.t()) :: String.t()
to_mention(user :: Crux.Structs.Role.t()) :: String.t()
Converts a Crux.Structs.Role.t/0
into its discord mention format.
Example
iex> %Crux.Structs.Role{id: 376146940762783746}
...> |> Crux.Structs.Role.to_mention()
"<@&376146940762783746>"