fix(RoleManager): allow null in RoleColorsResolvable to clear gradient colors (#11536)

* fix(RoleManager): allow null in RoleColorsResolvable to clear gradient colors

* docs(RoleManager): document nullable secondary/tertiary role colors

* refactor: split RoleColorsResolvable for create vs edit

* style: apply prettier formatting

* refactor: deduplicate RoleColors interfaces via inheritance

Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>

* refactor: move colors out of RoleData

---------

Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Aldin Čamdžić
2026-05-26 18:38:08 +02:00
committed by GitHub
parent c95cbf2678
commit 3d6121589f
3 changed files with 20 additions and 3 deletions

View File

@@ -130,6 +130,16 @@ class RoleManager extends CachedManager {
* These values are available as a constant: `Constants.HolographicStyle`
*/
/**
* @typedef {Object} RoleColorsEditResolvable
* @property {ColorResolvable} primaryColor The primary color of the role
* @property {?ColorResolvable} [secondaryColor] The secondary color of the role. Pass `null` to clear it.
* This will make the role a gradient between the other provided colors
* @property {?ColorResolvable} [tertiaryColor] The tertiary color of the role. Pass `null` to clear it.
* When sending `tertiaryColor` the API enforces the role color to be a holographic style with values of `primaryColor = 11127295`, `secondaryColor = 16759788`, and `tertiaryColor = 16761760`.
* These values are available as a constant: `Constants.HolographicStyle`
*/
/**
* Options used to create a new role.
*
@@ -223,6 +233,7 @@ class RoleManager extends CachedManager {
* Options for editing a role
*
* @typedef {RoleData} RoleEditOptions
* @property {RoleColorsEditResolvable} [colors] The colors to set on the role
* @property {string} [reason] The reason for editing this role
*/

View File

@@ -277,7 +277,6 @@ class Role extends Base {
*
* @typedef {Object} RoleData
* @property {string} [name] The name of the role
* @property {RoleColorsResolvable} [colors] The colors of the role
* @property {boolean} [hoist] Whether or not the role should be hoisted
* @property {number} [position] The position of the role
* @property {PermissionResolvable} [permissions] The permissions of the role

View File

@@ -3014,12 +3014,18 @@ export interface RoleColors {
tertiaryColor: number | null;
}
export interface RoleColorsResolvable {
export interface RoleColorsResolvable extends RoleColorsEditResolvable {
primaryColor: ColorResolvable;
secondaryColor?: ColorResolvable;
tertiaryColor?: ColorResolvable;
}
export interface RoleColorsEditResolvable {
primaryColor: ColorResolvable;
secondaryColor?: ColorResolvable | null;
tertiaryColor?: ColorResolvable | null;
}
export class Role extends Base {
private constructor(client: Client<true>, data: APIRole, guild: Guild);
public colors: RoleColors;
@@ -5896,10 +5902,12 @@ export interface GuildScheduledEventInviteURLCreateOptions extends InviteCreateO
}
export interface RoleCreateOptions extends RoleData {
colors?: RoleColorsResolvable;
reason?: string;
}
export interface RoleEditOptions extends RoleData {
colors?: RoleColorsEditResolvable;
reason?: string;
}
@@ -7136,7 +7144,6 @@ export interface ResolvedOverwriteOptions {
}
export interface RoleData {
colors?: RoleColorsResolvable;
hoist?: boolean;
icon?: Base64Resolvable | BufferResolvable | EmojiResolvable | null;
mentionable?: boolean;