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

Represents a Discord User Object

Link to this section Summary

Types

All available types that can be resolved into a user id.

t()

Functions

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

Converts a Crux.Structs.User.t/0 into its discord mention format.

Link to this section Types

All available types that can be resolved into a user id.

Link to this type

t() View Source (since 0.1.0)
t() :: %Crux.Structs.User{
  avatar: String.t() | nil,
  bot: boolean(),
  discriminator: String.t(),
  id: Crux.Structs.Snowflake.t(),
  username: String.t()
}

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.User.t/0 struct from raw data.

Automatically invoked by Crux.Structs.create/2.

Link to this function

resolve_id(resolvable) View Source (since 0.2.1)
resolve_id(id_resolvable()) :: Crux.Structs.Snowflake.t() | nil

Resolves the id of a Crux.Structs.Guild.t/0.

Automatically invoked by Crux.Structs.resolve_id/2.

  iex> %Crux.Structs.User{id: 218348062828003328}
  ...> |> Crux.Structs.User.resolve_id()
  218348062828003328

  iex> %Crux.Structs.Member{user: 218348062828003328}
  ...> |> Crux.Structs.User.resolve_id()
  218348062828003328

  iex> %Crux.Structs.Message{author: %Crux.Structs.User{id: 218348062828003328}}
  ...> |> Crux.Structs.User.resolve_id()
  218348062828003328

  iex> %Crux.Structs.Presence{user: 218348062828003328}
  ...> |> Crux.Structs.User.resolve_id()
  218348062828003328

  iex> %Crux.Structs.VoiceState{user_id: 218348062828003328}
  ...> |> Crux.Structs.User.resolve_id()
  218348062828003328

  iex> 218348062828003328
  ...> |> Crux.Structs.User.resolve_id()
  218348062828003328

  iex> "218348062828003328"
  ...> |> Crux.Structs.User.resolve_id()
  218348062828003328
Link to this function

to_mention(user) View Source (since 0.1.1)
to_mention(user :: Crux.Structs.User.t()) :: String.t()

Converts a Crux.Structs.User.t/0 into its discord mention format.

iex> %Crux.Structs.User{id: 218348062828003328}
...> |> Crux.Structs.User.to_mention()
"<@218348062828003328>"