Crux v2020-03-17 17:55:51Z Crux.Structs.Overwrite View Source

Represents a Discord Overwrite Object.

Link to this section Summary

Types

t()

All available types that can be resolved into a target for a permission overwrite

Functions

Creates a Crux.Structs.Overwrite.t/0 struct from raw data.

Resolves a target_resolvable/0 into an overwrite target.

Link to this section Types

Link to this type

t() View Source (since 0.1.0)
t() :: %Crux.Structs.Overwrite{
  allow: integer(),
  deny: integer(),
  id: Crux.Structs.Snowflake.t(),
  type: String.t()
}

All available types that can be resolved into a target for a permission overwrite

Link to this section Functions

Link to this function

create(data) View Source (since 0.1.0)
create(data :: map()) :: t()

Creates a Crux.Structs.Overwrite.t/0 struct from raw data.

Automatically invoked by Crux.Structs.create/2.

Link to this function

resolve_target(resolvable) View Source
resolve_target(target_resolvable()) ::
  {String.t() | :unknown, Crux.Structs.Snowflake.t()}

Resolves a target_resolvable/0 into an overwrite target.

Note that an id or string of it returns :unknown as type.

Examples

  iex> %Crux.Structs.Overwrite{type: "member", id: 218348062828003328}
  ...> |> Crux.Structs.Overwrite.resolve_target()
  {"member", 218348062828003328}

  iex> %Crux.Structs.Role{id: 376146940762783746}
  ...> |> Crux.Structs.Overwrite.resolve_target()
  {"role", 376146940762783746}

  iex> %Crux.Structs.User{id: 218348062828003328}
  ...> |> Crux.Structs.Overwrite.resolve_target()
  {"member", 218348062828003328}

  iex> %Crux.Structs.Member{user: 218348062828003328}
  ...> |> Crux.Structs.Overwrite.resolve_target()
  {"member", 218348062828003328}

  iex> %Crux.Structs.Message{author: %Crux.Structs.User{id: 218348062828003328}}
  ...> |> Crux.Structs.Overwrite.resolve_target()
  {"member", 218348062828003328}

  iex> %Crux.Structs.VoiceState{user_id: 218348062828003328}
  ...> |> Crux.Structs.Overwrite.resolve_target()
  {"member", 218348062828003328}

  iex> 218348062828003328
  ...> |> Crux.Structs.Overwrite.resolve_target()
  {:unknown, 218348062828003328}

  iex> "218348062828003328"
  ...> |> Crux.Structs.Overwrite.resolve_target()
  {:unknown, 218348062828003328}

  iex> nil
  ...> |> Crux.Structs.Overwrite.resolve_target()
  nil