feat: role gradient colors (#1281)

This commit is contained in:
Danial Raza
2025-06-27 11:58:57 +02:00
committed by GitHub
parent ef1f32acd0
commit 7fbb3e3310
12 changed files with 176 additions and 0 deletions

View File

@@ -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',
}
/**

View File

@@ -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;
}

View File

@@ -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',
}
/**

View File

@@ -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;
}

14
deno/rest/v10/guild.ts generated
View File

@@ -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
*/

14
deno/rest/v9/guild.ts generated
View File

@@ -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
*/

View File

@@ -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',
}
/**

View File

@@ -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;
}

View File

@@ -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',
}
/**

View File

@@ -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;
}

View File

@@ -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
*/

View File

@@ -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
*/