EDA.Guild (EDA v0.3.0)

Copy Markdown View Source

Represents a Discord guild.

Summary

Functions

Applies a changeset to a guild. 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.

Gets channels for a guild, returned as %EDA.Channel{} structs.

Deletes a guild. The bot must be the owner.

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

Fetches a guild by ID. Raises on error.

Returns the CDN URL for the guild's icon, or nil if the guild has no icon.

Modifies a guild. Accepts a struct or ID, a map of changes, and options.

Types

t()

@type t() :: %EDA.Guild{
  channels: [EDA.Channel.t()] | nil,
  icon: String.t() | nil,
  id: String.t() | nil,
  large: boolean() | nil,
  member_count: integer() | nil,
  members: [EDA.Member.t()] | nil,
  name: String.t() | nil,
  owner_id: String.t() | nil,
  presences: [map()] | nil,
  roles: [EDA.Role.t()] | nil,
  unavailable: boolean() | nil,
  voice_states: [map()] | nil
}

Functions

apply_changeset(changeset, opts \\ [])

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

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

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.

channels(guild_id)

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

Gets channels for a guild, returned as %EDA.Channel{} structs.

delete(guild_id)

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

Deletes a guild. The bot must be the owner.

fetch(guild_id)

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

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

Accepts a guild struct or a string/integer ID.

fetch!(guild_id)

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

Fetches a guild by ID. Raises on error.

from_raw(raw)

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

icon_url(guild)

@spec icon_url(t()) :: String.t() | nil

Returns the CDN URL for the guild's icon, or nil if the guild has no icon.

Examples

EDA.Guild.icon_url(guild)
#=> "https://cdn.discordapp.com/icons/123/abc.png"

modify(guild, payload, opts \\ [])

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

Modifies a guild. Accepts a struct or ID, a map of changes, and options.

Options

  • :reason - Audit log reason