crux_structs v0.2.3 Crux.Structs.Member View Source

Represents a Discord Guild Member 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 a user id.

t()

Functions

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

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

Link to this section Types

Link to this type

id_resolvable()

View Source (since 0.2.1)

Specs

id_resolvable() :: Crux.Structs.User.id_resolvable()

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

Specs

t() :: %Crux.Structs.Member{
  deaf: boolean() | nil,
  guild_id: Crux.Structs.Snowflake.t() | nil,
  joined_at: String.t(),
  mute: boolean() | nil,
  nick: String.t() | nil,
  premium_since: String.t() | nil,
  roles: MapSet.t(Crux.Structs.Snowflake.t()),
  user: Crux.Structs.Snowflake.t()
}

Link to this section Functions

Link to this function

create(data)

View Source (since 0.1.0)

Specs

create(data :: map()) :: t()

Creates a t:Crux.Structs.Member.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)

Specs

resolve_id(id_resolvable()) :: Crux.Structs.Snowflake.t() | nil

Resolves the id of a t:Crux.Structs.Member.t/0.

Automatically invoked by Crux.Structs.resolve_id/2.

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

For more examples see Crux.Structs.User.resolve_id/1.

Link to this function

to_mention(member)

View Source (since 0.1.1)

Specs

to_mention(user :: Crux.Structs.Member.t()) :: String.t()

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

Examples

# Without nickname
iex> %Crux.Structs.Member{user: 218348062828003328, nick: nil}
...> |> Crux.Structs.Member.to_mention()
"<@218348062828003328>"

# With nickname
iex> %Crux.Structs.Member{user: 218348062828003328, nick: "weltraum"}
...> |> Crux.Structs.Member.to_mention()
"<@!218348062828003328>"