EDA.Role (EDA v0.3.0)

Copy Markdown View Source

Represents a Discord guild role.

Summary

Functions

Applies a changeset to a role. No-op if the changeset has no changes.

Adds a change to an existing changeset for this entity.

Creates a changeset for batching mutations to this entity.

Creates a role in a guild.

Deletes a guild role.

Fetches a role by guild ID and role ID. Checks cache first, falls back to REST.

Returns a mention string like <@&id>.

Types

t()

@type t() :: %EDA.Role{
  color: integer() | nil,
  hoist: boolean() | nil,
  icon: String.t() | nil,
  id: String.t() | nil,
  managed: boolean() | nil,
  mentionable: boolean() | nil,
  name: String.t() | nil,
  permissions: String.t() | nil,
  position: integer() | nil,
  tags: map() | nil,
  unicode_emoji: String.t() | nil
}

Functions

apply_changeset(guild_id, changeset, opts \\ [])

@spec apply_changeset(String.t() | integer(), EDA.Entity.Changeset.t(), keyword()) ::
  {:ok, t()} | {:error, term()}

Applies a changeset to a role. No-op if the changeset has no changes.

Requires guild_id since roles are guild-scoped.

Options

  • :reason - Audit log reason

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(guild_id, params \\ [], opts \\ [])

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

Creates a role in a guild.

Options

  • :reason - Audit log reason

delete(guild_id, role, opts \\ [])

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

Deletes a guild role.

Options

  • :reason - Audit log reason

fetch_role(guild_id, role_id)

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

Fetches a role by guild ID and role ID. Checks cache first, falls back to REST.

from_raw(raw)

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

mention(role)

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

Returns a mention string like <@&id>.

modify(guild_id, role, payload, opts \\ [])

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

Modifies a guild role.

Options

  • :reason - Audit log reason