A role's colours: solid, gradient, or holographic.
Supersedes the role's single color field, which Discord deprecated — JDA marks
its equivalent getColor() as @ReplaceWith("getColors().getPrimary()"), and
discord.js sends only colors when editing a role, never color.
Four styles
style/1 returns :default, :solid, :gradient or :holographic, mirroring JDA's
isDefault() / isSolid() / isGradient() / isHolographic(). Two distinctions matter:
:default— no colour at all. Discord represents this asprimary_color: 0, which is not the same as an explicitly chosen black. Measured across 201 roles on 8 real guilds, 78 were in this state — 39%, and only 8 of those were@everyone. Treating them as solid would mis-colour most of a typical guild's roles;:solid— a real single colour;:gradient—secondary_coloris set,tertiary_coloris not;:holographic—tertiary_coloris set, and Discord then forces all three values to11127295,16759788,16761760. You cannot pick your own holographic colours. Useholographic/0rather than writing them out.
Reading
role.colors
#=> %EDA.Role.Colors{primary_color: 10382335, secondary_color: 12427263, tertiary_color: nil}
EDA.Role.Colors.style(role.colors) #=> :gradientWriting
EDA.Role.set_colors(guild_id, role_id, EDA.Role.Colors.gradient(0xFF0000, 0x00FF00))
EDA.Role.set_colors(guild_id, role_id, EDA.Role.Colors.holographic())
EDA.Role.set_colors(guild_id, role_id, EDA.Role.Colors.solid(0x5865F2))Writing needs an eligible guild
Setting a gradient or holographic colour on an ineligible guild fails with HTTP 403,
code 670006 "Missing guild feature" (EDA.Error.missing_guild_feature/0). The
relevant feature is not advertised: ENHANCED_ROLE_COLORS appeared in no guild's
features array, including one with seven gradient roles already in place. So there is
no reliable pre-check — attempt the write and handle the error. Reading is unaffected.
Observed behaviour
Probed against a real guild (2026-09-19): every role carried all three keys,
primary_color equalled the legacy color on all 57 roles, and 7 used a gradient.
The ENHANCED_ROLE_COLORS guild feature was absent despite gradients being in
use, so do not gate reads on that feature.
Summary
Functions
Returns true when the role has no colour of its own.
Parses the raw colors object. Returns nil when absent.
A two-colour gradient.
Returns true for a two-colour gradient — not for holographic roles.
The holographic style, with the three values Discord enforces.
Returns true for the holographic style.
The primary_color Discord enforces for holographic roles.
The secondary_color Discord enforces for holographic roles.
The tertiary_color Discord enforces for holographic roles.
A solid, single-colour role.
Returns true for a role with one real colour — not for an uncoloured role.
Returns the colour style: :default, :solid, :gradient or :holographic.
Converts to the snake_case object Discord expects in a role payload.
Types
Functions
Returns true when the role has no colour of its own.
Examples
iex> EDA.Role.Colors.default?(%EDA.Role.Colors{primary_color: 0})
true
iex> EDA.Role.Colors.default?(%EDA.Role.Colors{primary_color: 1})
false
iex> EDA.Role.Colors.default?(nil)
true
Parses the raw colors object. Returns nil when absent.
A two-colour gradient.
Examples
iex> EDA.Role.Colors.gradient(0xFF0000, 0x00FF00)
%EDA.Role.Colors{primary_color: 16711680, secondary_color: 65280, tertiary_color: nil}
Returns true for a two-colour gradient — not for holographic roles.
Examples
iex> EDA.Role.Colors.gradient?(%EDA.Role.Colors{primary_color: 1, secondary_color: 2})
true
iex> EDA.Role.Colors.gradient?(EDA.Role.Colors.holographic())
false
iex> EDA.Role.Colors.gradient?(nil)
false
@spec holographic() :: t()
The holographic style, with the three values Discord enforces.
Discord ignores any other values once tertiary_color is sent, so this takes no
arguments on purpose.
Examples
iex> EDA.Role.Colors.holographic()
%EDA.Role.Colors{primary_color: 11127295, secondary_color: 16759788, tertiary_color: 16761760}
Returns true for the holographic style.
Examples
iex> EDA.Role.Colors.holographic?(EDA.Role.Colors.holographic())
true
iex> EDA.Role.Colors.holographic?(%EDA.Role.Colors{primary_color: 1, secondary_color: 2})
false
@spec holographic_primary() :: integer()
The primary_color Discord enforces for holographic roles.
@spec holographic_secondary() :: integer()
The secondary_color Discord enforces for holographic roles.
@spec holographic_tertiary() :: integer()
The tertiary_color Discord enforces for holographic roles.
A solid, single-colour role.
Examples
iex> EDA.Role.Colors.solid(0x5865F2)
%EDA.Role.Colors{primary_color: 5793266, secondary_color: nil, tertiary_color: nil}
Returns true for a role with one real colour — not for an uncoloured role.
Examples
iex> EDA.Role.Colors.solid?(%EDA.Role.Colors{primary_color: 1})
true
iex> EDA.Role.Colors.solid?(%EDA.Role.Colors{primary_color: 0})
false
iex> EDA.Role.Colors.solid?(EDA.Role.Colors.holographic())
false
Returns the colour style: :default, :solid, :gradient or :holographic.
primary_color: 0 means no colour, not black — it is :default, as in JDA.
Examples
iex> EDA.Role.Colors.style(%EDA.Role.Colors{primary_color: 1})
:solid
iex> EDA.Role.Colors.style(%EDA.Role.Colors{primary_color: 0})
:default
iex> EDA.Role.Colors.style(%EDA.Role.Colors{primary_color: 1, secondary_color: 2})
:gradient
iex> EDA.Role.Colors.style(EDA.Role.Colors.holographic())
:holographic
iex> EDA.Role.Colors.style(nil)
:default
Converts to the snake_case object Discord expects in a role payload.
Keys whose value is nil are omitted rather than sent as null, so a solid colour
does not clear a gradient by accident.
Examples
iex> EDA.Role.Colors.to_map(EDA.Role.Colors.solid(255))
%{primary_color: 255}
iex> EDA.Role.Colors.to_map(EDA.Role.Colors.gradient(1, 2))
%{primary_color: 1, secondary_color: 2}