From 3d6121589f9c0d91f7cf4976307e8be07053a277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aldin=20=C4=8Camd=C5=BEi=C4=87?= Date: Tue, 26 May 2026 18:38:08 +0200 Subject: [PATCH] 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> --- packages/discord.js/src/managers/RoleManager.js | 11 +++++++++++ packages/discord.js/src/structures/Role.js | 1 - packages/discord.js/typings/index.d.ts | 11 +++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/discord.js/src/managers/RoleManager.js b/packages/discord.js/src/managers/RoleManager.js index bf117b5d2..fab299d9d 100644 --- a/packages/discord.js/src/managers/RoleManager.js +++ b/packages/discord.js/src/managers/RoleManager.js @@ -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 */ diff --git a/packages/discord.js/src/structures/Role.js b/packages/discord.js/src/structures/Role.js index ca6014926..5c76559aa 100644 --- a/packages/discord.js/src/structures/Role.js +++ b/packages/discord.js/src/structures/Role.js @@ -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 diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 32085334a..6ef607587 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -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, 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;