From 7fbb3e3310bde5ea0e977afb83ea21bda0220633 Mon Sep 17 00:00:00 2001 From: Danial Raza Date: Fri, 27 Jun 2025 11:58:57 +0200 Subject: [PATCH] feat: role gradient colors (#1281) --- deno/payloads/v10/guild.ts | 4 ++++ deno/payloads/v10/permissions.ts | 26 ++++++++++++++++++++++++++ deno/payloads/v9/guild.ts | 4 ++++ deno/payloads/v9/permissions.ts | 26 ++++++++++++++++++++++++++ deno/rest/v10/guild.ts | 14 ++++++++++++++ deno/rest/v9/guild.ts | 14 ++++++++++++++ payloads/v10/guild.ts | 4 ++++ payloads/v10/permissions.ts | 26 ++++++++++++++++++++++++++ payloads/v9/guild.ts | 4 ++++ payloads/v9/permissions.ts | 26 ++++++++++++++++++++++++++ rest/v10/guild.ts | 14 ++++++++++++++ rest/v9/guild.ts | 14 ++++++++++++++ 12 files changed, 176 insertions(+) diff --git a/deno/payloads/v10/guild.ts b/deno/payloads/v10/guild.ts index b5a3f560..8de64b27 100644 --- a/deno/payloads/v10/guild.ts +++ b/deno/payloads/v10/guild.ts @@ -565,6 +565,10 @@ export enum GuildFeature { * Guild has enabled the welcome screen */ WelcomeScreenEnabled = 'WELCOME_SCREEN_ENABLED', + /** + * Guild is able to set gradient colors to roles + */ + EnhancedRoleColors = 'ENHANCED_ROLE_COLORS', } /** diff --git a/deno/payloads/v10/permissions.ts b/deno/payloads/v10/permissions.ts index 3ebbfdf1..d97c8e7b 100644 --- a/deno/payloads/v10/permissions.ts +++ b/deno/payloads/v10/permissions.ts @@ -18,8 +18,14 @@ export interface APIRole { name: string; /** * Integer representation of hexadecimal color code + * + * @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests. */ color: number; + /** + * The role's colors + */ + colors?: APIRoleColors; /** * If this role is pinned in the user listing */ @@ -99,3 +105,23 @@ export enum RoleFlags { */ InPrompt = 1 << 0, } + +/** + * @see {@link https://discord.com/developers/docs/topics/permissions#role-colors-object} + */ +export interface APIRoleColors { + /** + * The primary color for the role + */ + primary_color: number; + /** + * The secondary color for the role, this will make the role a gradient between the other provided colors + */ + secondary_color: number | null; + /** + * The tertiary color for the role, this will turn the gradient into a holographic style + * + * @remarks When sending `tertiary_color` the API enforces the role color to be a holographic style with values of `primary_color = 11127295`, `secondary_color = 16759788`, and `tertiary_color = 16761760`. + */ + tertiary_color: number | null; +} diff --git a/deno/payloads/v9/guild.ts b/deno/payloads/v9/guild.ts index 2a8e41fb..fd8154e9 100644 --- a/deno/payloads/v9/guild.ts +++ b/deno/payloads/v9/guild.ts @@ -557,6 +557,10 @@ export enum GuildFeature { * Guild has enabled the welcome screen */ WelcomeScreenEnabled = 'WELCOME_SCREEN_ENABLED', + /** + * Guild is able to set gradient colors to roles + */ + EnhancedRoleColors = 'ENHANCED_ROLE_COLORS', } /** diff --git a/deno/payloads/v9/permissions.ts b/deno/payloads/v9/permissions.ts index 3ebbfdf1..d97c8e7b 100644 --- a/deno/payloads/v9/permissions.ts +++ b/deno/payloads/v9/permissions.ts @@ -18,8 +18,14 @@ export interface APIRole { name: string; /** * Integer representation of hexadecimal color code + * + * @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests. */ color: number; + /** + * The role's colors + */ + colors?: APIRoleColors; /** * If this role is pinned in the user listing */ @@ -99,3 +105,23 @@ export enum RoleFlags { */ InPrompt = 1 << 0, } + +/** + * @see {@link https://discord.com/developers/docs/topics/permissions#role-colors-object} + */ +export interface APIRoleColors { + /** + * The primary color for the role + */ + primary_color: number; + /** + * The secondary color for the role, this will make the role a gradient between the other provided colors + */ + secondary_color: number | null; + /** + * The tertiary color for the role, this will turn the gradient into a holographic style + * + * @remarks When sending `tertiary_color` the API enforces the role color to be a holographic style with values of `primary_color = 11127295`, `secondary_color = 16759788`, and `tertiary_color = 16761760`. + */ + tertiary_color: number | null; +} diff --git a/deno/rest/v10/guild.ts b/deno/rest/v10/guild.ts index 55350cbe..7c512063 100644 --- a/deno/rest/v10/guild.ts +++ b/deno/rest/v10/guild.ts @@ -26,6 +26,7 @@ import type { GuildWidgetStyle, APIGuildOnboardingPrompt, APIGuildOnboardingPromptOption, + APIRoleColors, } from '../../payloads/v10/mod.ts'; import type { _AddUndefinedToPossiblyUndefinedPropertiesOfInterface, @@ -676,8 +677,15 @@ export interface RESTPostAPIGuildRoleJSONBody { * RGB color value * * @defaultValue `0` + * @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests. */ color?: number | null | undefined; + /** + * The role's colors + * + * @defaultValue `{ "primary_color": 0, "secondary_color": null, "tertiary_color": null }` + */ + colors?: APIRoleColors | undefined; /** * Whether the role should be displayed separately in the sidebar * @@ -738,8 +746,14 @@ export interface RESTPatchAPIGuildRoleJSONBody { permissions?: Permissions | null | undefined; /** * RGB color value + * + * @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests. */ color?: number | null | undefined; + /** + * The role's colors + */ + colors?: APIRoleColors | undefined; /** * Whether the role should be displayed separately in the sidebar */ diff --git a/deno/rest/v9/guild.ts b/deno/rest/v9/guild.ts index 32b24149..60182032 100644 --- a/deno/rest/v9/guild.ts +++ b/deno/rest/v9/guild.ts @@ -26,6 +26,7 @@ import type { APIGroupDMChannel, APIGuildOnboardingPrompt, APIGuildOnboardingPromptOption, + APIRoleColors, } from '../../payloads/v9/mod.ts'; import type { _AddUndefinedToPossiblyUndefinedPropertiesOfInterface, @@ -682,8 +683,15 @@ export interface RESTPostAPIGuildRoleJSONBody { * RGB color value * * @defaultValue `0` + * @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests. */ color?: number | null | undefined; + /** + * The role's colors + * + * @defaultValue `{ "primary_color": 0, "secondary_color": null, "tertiary_color": null }` + */ + colors?: APIRoleColors | undefined; /** * Whether the role should be displayed separately in the sidebar * @@ -744,8 +752,14 @@ export interface RESTPatchAPIGuildRoleJSONBody { permissions?: Permissions | null | undefined; /** * RGB color value + * + * @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests. */ color?: number | null | undefined; + /** + * The role's colors + */ + colors?: APIRoleColors | undefined; /** * Whether the role should be displayed separately in the sidebar */ diff --git a/payloads/v10/guild.ts b/payloads/v10/guild.ts index 0063cbc1..b8faad81 100644 --- a/payloads/v10/guild.ts +++ b/payloads/v10/guild.ts @@ -565,6 +565,10 @@ export enum GuildFeature { * Guild has enabled the welcome screen */ WelcomeScreenEnabled = 'WELCOME_SCREEN_ENABLED', + /** + * Guild is able to set gradient colors to roles + */ + EnhancedRoleColors = 'ENHANCED_ROLE_COLORS', } /** diff --git a/payloads/v10/permissions.ts b/payloads/v10/permissions.ts index 72d94df0..9a48234c 100644 --- a/payloads/v10/permissions.ts +++ b/payloads/v10/permissions.ts @@ -18,8 +18,14 @@ export interface APIRole { name: string; /** * Integer representation of hexadecimal color code + * + * @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests. */ color: number; + /** + * The role's colors + */ + colors?: APIRoleColors; /** * If this role is pinned in the user listing */ @@ -99,3 +105,23 @@ export enum RoleFlags { */ InPrompt = 1 << 0, } + +/** + * @see {@link https://discord.com/developers/docs/topics/permissions#role-colors-object} + */ +export interface APIRoleColors { + /** + * The primary color for the role + */ + primary_color: number; + /** + * The secondary color for the role, this will make the role a gradient between the other provided colors + */ + secondary_color: number | null; + /** + * The tertiary color for the role, this will turn the gradient into a holographic style + * + * @remarks When sending `tertiary_color` the API enforces the role color to be a holographic style with values of `primary_color = 11127295`, `secondary_color = 16759788`, and `tertiary_color = 16761760`. + */ + tertiary_color: number | null; +} diff --git a/payloads/v9/guild.ts b/payloads/v9/guild.ts index 2b2188f3..f909f4bb 100644 --- a/payloads/v9/guild.ts +++ b/payloads/v9/guild.ts @@ -557,6 +557,10 @@ export enum GuildFeature { * Guild has enabled the welcome screen */ WelcomeScreenEnabled = 'WELCOME_SCREEN_ENABLED', + /** + * Guild is able to set gradient colors to roles + */ + EnhancedRoleColors = 'ENHANCED_ROLE_COLORS', } /** diff --git a/payloads/v9/permissions.ts b/payloads/v9/permissions.ts index 72d94df0..9a48234c 100644 --- a/payloads/v9/permissions.ts +++ b/payloads/v9/permissions.ts @@ -18,8 +18,14 @@ export interface APIRole { name: string; /** * Integer representation of hexadecimal color code + * + * @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests. */ color: number; + /** + * The role's colors + */ + colors?: APIRoleColors; /** * If this role is pinned in the user listing */ @@ -99,3 +105,23 @@ export enum RoleFlags { */ InPrompt = 1 << 0, } + +/** + * @see {@link https://discord.com/developers/docs/topics/permissions#role-colors-object} + */ +export interface APIRoleColors { + /** + * The primary color for the role + */ + primary_color: number; + /** + * The secondary color for the role, this will make the role a gradient between the other provided colors + */ + secondary_color: number | null; + /** + * The tertiary color for the role, this will turn the gradient into a holographic style + * + * @remarks When sending `tertiary_color` the API enforces the role color to be a holographic style with values of `primary_color = 11127295`, `secondary_color = 16759788`, and `tertiary_color = 16761760`. + */ + tertiary_color: number | null; +} diff --git a/rest/v10/guild.ts b/rest/v10/guild.ts index 7daa242a..5cc9266b 100644 --- a/rest/v10/guild.ts +++ b/rest/v10/guild.ts @@ -26,6 +26,7 @@ import type { GuildWidgetStyle, APIGuildOnboardingPrompt, APIGuildOnboardingPromptOption, + APIRoleColors, } from '../../payloads/v10/index'; import type { _AddUndefinedToPossiblyUndefinedPropertiesOfInterface, @@ -676,8 +677,15 @@ export interface RESTPostAPIGuildRoleJSONBody { * RGB color value * * @defaultValue `0` + * @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests. */ color?: number | null | undefined; + /** + * The role's colors + * + * @defaultValue `{ "primary_color": 0, "secondary_color": null, "tertiary_color": null }` + */ + colors?: APIRoleColors | undefined; /** * Whether the role should be displayed separately in the sidebar * @@ -738,8 +746,14 @@ export interface RESTPatchAPIGuildRoleJSONBody { permissions?: Permissions | null | undefined; /** * RGB color value + * + * @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests. */ color?: number | null | undefined; + /** + * The role's colors + */ + colors?: APIRoleColors | undefined; /** * Whether the role should be displayed separately in the sidebar */ diff --git a/rest/v9/guild.ts b/rest/v9/guild.ts index 6a9dde5a..76ec95ba 100644 --- a/rest/v9/guild.ts +++ b/rest/v9/guild.ts @@ -26,6 +26,7 @@ import type { APIGroupDMChannel, APIGuildOnboardingPrompt, APIGuildOnboardingPromptOption, + APIRoleColors, } from '../../payloads/v9/index'; import type { _AddUndefinedToPossiblyUndefinedPropertiesOfInterface, @@ -682,8 +683,15 @@ export interface RESTPostAPIGuildRoleJSONBody { * RGB color value * * @defaultValue `0` + * @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests. */ color?: number | null | undefined; + /** + * The role's colors + * + * @defaultValue `{ "primary_color": 0, "secondary_color": null, "tertiary_color": null }` + */ + colors?: APIRoleColors | undefined; /** * Whether the role should be displayed separately in the sidebar * @@ -744,8 +752,14 @@ export interface RESTPatchAPIGuildRoleJSONBody { permissions?: Permissions | null | undefined; /** * RGB color value + * + * @remarks `color` will still be returned by the API, but using the `colors` field is recommended when doing requests. */ color?: number | null | undefined; + /** + * The role's colors + */ + colors?: APIRoleColors | undefined; /** * Whether the role should be displayed separately in the sidebar */