Skip to content

add support for enhanced role colors ( gradient and holograpic )#3246

Merged
quinchs merged 5 commits into
discord-net:devfrom
codekm92:enhancedrolecolors
Mar 12, 2026
Merged

add support for enhanced role colors ( gradient and holograpic )#3246
quinchs merged 5 commits into
discord-net:devfrom
codekm92:enhancedrolecolors

Conversation

@codekm92

@codekm92 codekm92 commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Description

Until now, roles could only use the legacy color field, which only supports a single solid color. Discord's API exposes a colors object on roles, allowing enhanced role color configurations through primary_color, secondary_color, and tertiary_color.

This changeset introduces a dedicated RoleColors value type, exposes enhanced colors on role entities, adds support for sending and receiving the colors payload in REST and gateway models, and extends role creation/modification APIs in a way that remains backward-compatible with the existing Color API.

It also handles Discord's special tertiary color requirement: whenever tertiary_color is sent, the payload is normalized to Discord's required holographic color triplet.

Changes

  • Add a new RoleColors value type to represent enhanced role colors.
  • Expose enhanced role colors through IRole.Colors.
  • Add RoleProperties.Colors so roles can be modified with enhanced colors.
  • Keep the existing IRole.Color and RoleProperties.Color behavior for backward compatibility.
  • Extend role create APIs with new CreateRoleAsync overloads that accept RoleColors.
  • Update REST role models to deserialize the API colors object.
  • Update modify/create role REST payloads to serialize the API colors object.
  • Add conversion helpers between API models and the new RoleColors entity type.
  • Update RestRole and SocketRole to surface enhanced role colors.
  • Add support for enhanced role colors in role audit log data.
  • Add the EnhancedRoleColors guild feature and validate it before sending enhanced color payloads.
  • Allow enhanced color payloads with nullable primary_color, matching Discord's API behavior.
  • Normalize any payload containing tertiary_color to Discord's required holographic values:
    • primary_color = 11127295
    • secondary_color = 16759788
    • tertiary_color = 16761760
  • Preserve existing single-color behavior by continuing to populate the legacy color field when appropriate.
  • Add fallback handling so roles without a colors object still expose a compatible single-color representation where possible.

Comment thread src/Discord.Net.Core/Entities/Roles/IRole.cs Outdated
Comment thread src/Discord.Net.Rest/API/Common/Role.cs Outdated
Comment thread src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs Outdated
Comment thread src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs Outdated
Comment thread src/Discord.Net.Rest/API/Common/RoleColors.cs Outdated
Comment thread src/Discord.Net.Rest/API/Common/RoleColors.cs Outdated
Comment thread src/Discord.Net.Rest/Entities/Roles/RestRole.cs Outdated
Comment thread src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs Outdated
Comment thread src/Discord.Net.WebSocket/Entities/Roles/SocketRole.cs Outdated
@Misha-133

Copy link
Copy Markdown
Member

Hm, seems like it may indeed be null
discord/discord-api-docs#8199

@codekm92

codekm92 commented Mar 9, 2026

Copy link
Copy Markdown
Contributor Author

everything you mentioned is fixed and i hope i did not forget anything else @Misha-133
i already tested this PR complete with creating and editing a role with colors and getting all informations from discord about the role with no errors.

@codekm92 codekm92 force-pushed the enhancedrolecolors branch from 1f9f23a to ef2d7ab Compare March 9, 2026 16:45
@codekm92 codekm92 force-pushed the enhancedrolecolors branch from ef2d7ab to 0065570 Compare March 9, 2026 16:49
@quinchs

quinchs commented Mar 11, 2026

Copy link
Copy Markdown
Member

I've gone ahead and made some changes:

  • Made RoleColors a readonly record struct.
  • Added implicit conversions for RoleColors.
  • Removed new methods and overloads for the new RoleColors type, updating the old methods to use the new type which shouldn't be breaking due to implicit conversions.
  • Added proper nullable conversions to Color and RoleColors.
  • Added xml docs and Obsolete to Color properties where applicable, making its value point to Colors.PrimaryColor.
  • Updated API model construction to not set the color property.
  • Made Colors non-nullable, falling back to the API color field if its not specified by the API.

@quinchs quinchs requested a review from Misha-133 March 11, 2026 12:12
@quinchs quinchs merged commit 3e8aacf into discord-net:dev Mar 12, 2026
2 checks passed
kshitijanurag pushed a commit to kshitijanurag/Discord.Net that referenced this pull request Mar 20, 2026
…cord-net#3246)

* added support for enhanced role colors ( gradient and holograpic )

* colors is nullable not optional

* colors object now follows api documentation.

* wrapping createroleasync with color param to new with rolecolors param

* update RoleColors object and usage

---------

Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants