EDA.User (EDA v0.3.0)

Copy Markdown View Source

Represents a Discord user.

Summary

Functions

Returns the CDN URL for the user's avatar, or nil if none set.

Returns true if the user is a bot. Accepts structs and raw maps.

Adds a change to an existing changeset for this entity.

Creates a changeset for batching mutations to this entity.

Creates a DM channel with a user. Returns a %EDA.Channel{} struct.

Returns the display name (global_name if set, otherwise username).

Fetches a user by ID. Checks cache first, falls back to REST.

Fetches a user by ID. Raises on error.

Returns a mention string like <@id>. Accepts structs and raw maps.

Types

t()

@type t() :: %EDA.User{
  accent_color: integer() | nil,
  avatar: String.t() | nil,
  banner: String.t() | nil,
  bot: boolean() | nil,
  discriminator: String.t() | nil,
  flags: integer() | nil,
  global_name: String.t() | nil,
  id: String.t() | nil,
  public_flags: integer() | nil,
  system: boolean() | nil,
  username: String.t() | nil
}

Functions

avatar_url(arg1)

@spec avatar_url(t() | map()) :: String.t() | nil

Returns the CDN URL for the user's avatar, or nil if none set.

Accepts both %EDA.User{} structs and raw maps (from cache).

bot?(arg1)

@spec bot?(t() | map()) :: boolean()

Returns true if the user is a bot. Accepts structs and raw maps.

change(cs, key, value)

Adds a change to an existing changeset for this entity.

changeset(entity)

@spec changeset(t()) :: EDA.Entity.Changeset.t()

Creates a changeset for batching mutations to this entity.

create_dm(user_id)

@spec create_dm(t() | String.t() | integer()) ::
  {:ok, EDA.Channel.t()} | {:error, term()}

Creates a DM channel with a user. Returns a %EDA.Channel{} struct.

display_name(arg1)

@spec display_name(t() | map()) :: String.t() | nil

Returns the display name (global_name if set, otherwise username).

Accepts both %EDA.User{} structs and raw maps (from cache).

fetch(user_id)

@spec fetch(t() | String.t() | integer()) :: {:ok, t()} | {:error, term()}

Fetches a user by ID. Checks cache first, falls back to REST.

fetch!(user_id)

@spec fetch!(t() | String.t() | integer()) :: t()

Fetches a user by ID. Raises on error.

from_raw(raw)

@spec from_raw(map()) :: t()

mention(arg1)

@spec mention(t() | map()) :: String.t()

Returns a mention string like <@id>. Accepts structs and raw maps.