EDA.User.PrimaryGuild (EDA v0.4.0)

Copy Markdown View Source

A user's primary guild — the "server tag" shown next to their name.

Optional and nullable on the user object: the key is present for every user, but is nil unless they display a tag. Observed on a real guild (2026-09-19): 160 of 574 cached users had a non-nil value.

identity_enabled is deliberately tri-state — true when the tag is shown, false when the user removed it manually, and nil when Discord cleared the identity itself.

Example

%EDA.User.PrimaryGuild{
  identity_guild_id: "1508992262657409046",
  identity_enabled: true,
  tag: "BABL",
  badge: "22957f5661c149eefe1ba25d2bec7060"
}

Summary

Functions

URL of the server tag badge, or nil when there is none.

Returns true only when the user is actually displaying a server tag.

Parses the raw primary_guild object. Returns nil when absent or null.

Types

t()

@type t() :: %EDA.User.PrimaryGuild{
  badge: String.t() | nil,
  identity_enabled: boolean() | nil,
  identity_guild_id: String.t() | nil,
  tag: String.t() | nil
}

Functions

badge_url(primary_guild, opts \\ [])

@spec badge_url(
  t() | nil,
  keyword()
) :: String.t() | nil

URL of the server tag badge, or nil when there is none.

Options

  • :size — power of two between 16 and 4096

Examples

iex> EDA.User.PrimaryGuild.badge_url(%EDA.User.PrimaryGuild{identity_guild_id: "1", badge: "abc"})
"https://cdn.discordapp.com/guild-tag-badges/1/abc.png"

displayed?(arg1)

@spec displayed?(t() | nil) :: boolean()

Returns true only when the user is actually displaying a server tag.

Guards against the tri-state identity_enabled and against a tag being present while disabled.

Examples

iex> EDA.User.PrimaryGuild.displayed?(%EDA.User.PrimaryGuild{identity_enabled: true, tag: "DISC"})
true

iex> EDA.User.PrimaryGuild.displayed?(%EDA.User.PrimaryGuild{identity_enabled: false, tag: "DISC"})
false

iex> EDA.User.PrimaryGuild.displayed?(nil)
false

from_raw(raw)

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

Parses the raw primary_guild object. Returns nil when absent or null.