diff --git a/index.d.ts b/index.d.ts index 6cd2a5d39..e594e338c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -859,6 +859,7 @@ declare namespace Eris { } interface OldRole { color: number; + colors: RoleColors; flags: number; hoist: boolean; icon: string | null; @@ -1805,8 +1806,14 @@ declare namespace Eris { permissions?: number; position?: number; } + interface RoleColors { + primaryColor: number; + secondaryColor?: number | null; + tertiaryColor?: number | null; + } interface RoleOptions { color?: number; + colors?: RoleColors; hoist?: boolean; icon?: string; mentionable?: boolean; @@ -3268,6 +3275,7 @@ declare namespace Eris { export class Role extends Base { color: number; + colors: RoleColors; createdAt: number; flags: number; guild: Guild; diff --git a/lib/Client.js b/lib/Client.js index 97f9ea634..13b213619 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -1027,6 +1027,10 @@ class Client extends EventEmitter { * @arg {String} guildID The ID of the guild to create the role in * @arg {Object | Role} [options] An object or Role containing the properties to set * @arg {Number} [options.color] The hex color of the role, in number form (ex: 0x3d15b3 or 4040115) + * @arg {Object} [options.colors] The role's colors + * @arg {Number} [options.colors.primaryColor] The primary color of the role + * @arg {Number?} [options.colors.secondaryColor] The secondary color of the role (for gradient roles) + * @arg {Number?} [options.colors.tertiaryColor] The tertiary color of the role (for holographic roles) * @arg {Boolean} [options.hoist] Whether to hoist the role in the user list or not * @arg {String} [options.icon] The role icon as a base64 data URI * @arg {Boolean} [options.mentionable] Whether the role is mentionable or not @@ -1044,6 +1048,11 @@ class Client extends EventEmitter { name: options.name, permissions: options.permissions, color: options.color, + colors: options.colors && { + primary_color: options.colors.primaryColor, + secondary_color: options.colors.secondaryColor, + tertiary_color: options.colors.tertiaryColor, + }, hoist: options.hoist, icon: options.icon, mentionable: options.mentionable, @@ -2152,6 +2161,10 @@ class Client extends EventEmitter { * @arg {String} roleID The ID of the role * @arg {Object} options The properties to edit * @arg {Number} [options.color] The hex color of the role, in number form (ex: 0x3da5b3 or 4040115) + * @arg {Object} [options.colors] The role's colors + * @arg {Number} [options.colors.primaryColor] The primary color of the role + * @arg {Number?} [options.colors.secondaryColor] The secondary color of the role (for gradient roles) + * @arg {Number?} [options.colors.tertiaryColor] The tertiary color of the role (for holographic roles) * @arg {Boolean} [options.hoist] Whether to hoist the role in the user list or not * @arg {String} [options.icon] The role icon as a base64 data URI * @arg {Boolean} [options.mentionable] Whether the role is mentionable or not @@ -2167,6 +2180,13 @@ class Client extends EventEmitter { if (options.permissions !== undefined) { options.permissions = options.permissions instanceof Permission ? String(options.permissions.allow) : String(options.permissions); } + if (options.colors !== undefined) { + options.colors = { + primary_color: options.colors.primaryColor, + secondary_color: options.colors.secondaryColor, + tertiary_color: options.colors.tertiaryColor, + }; + } return this.requestHandler.request("PATCH", Endpoints.GUILD_ROLE(guildID, roleID), true, options).then((role) => new Role(role, this.guilds.get(guildID))); } diff --git a/lib/Constants.d.ts b/lib/Constants.d.ts index 402157741..c9cf368e7 100644 --- a/lib/Constants.d.ts +++ b/lib/Constants.d.ts @@ -234,6 +234,7 @@ export default interface Constants { "CREATOR_STORE_PAGE", "DEVELOPER_SUPPORT_SERVER", "DISCOVERABLE", + "ENHANCED_ROLE_COLORS", "FEATURABLE", "INVITES_DISABLED", "INVITE_SPLASH", diff --git a/lib/Constants.js b/lib/Constants.js index c0de89331..4107cb284 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -274,6 +274,7 @@ module.exports.GuildFeatures = [ "CREATOR_STORE_PAGE", "DEVELOPER_SUPPORT_SERVER", "DISCOVERABLE", + "ENHANCED_ROLE_COLORS", "FEATURABLE", "INVITE_SPLASH", "INVITES_DISABLED", diff --git a/lib/gateway/Shard.js b/lib/gateway/Shard.js index 32882ccf6..f465b4ee5 100644 --- a/lib/gateway/Shard.js +++ b/lib/gateway/Shard.js @@ -1618,6 +1618,7 @@ class Shard extends EventEmitter { } const oldRole = { color: role.color, + colors: role.colors, flags: role.flags, hoist: role.hoist, icon: role.icon, @@ -1636,6 +1637,10 @@ class Shard extends EventEmitter { * @prop {Role} role The updated role * @prop {Object} oldRole The old role data * @prop {Number} oldRole.color The hex color of the role in base 10 + * @prop {Object} oldRole.colors The role's colors + * @prop {Number} oldRole.colors.primaryColor The primary color of the role + * @prop {Number?} oldRole.colors.secondaryColor The secondary color of the role (for gradient roles) + * @prop {Number?} oldRole.colors.tertiaryColor The tertiary color of the role (for holographic roles) * @prop {Number} oldRole.flags The flags of the role (see constants) * @prop {Boolean} oldRole.hoist Whether users with the role are hoisted in the user list or not * @prop {String?} oldRole.icon The hash of the role's icon, or null if no icon diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index bde1ab571..12eaff0c4 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -520,6 +520,10 @@ class Guild extends Base { * Create a guild role * @arg {Object | Role} [options] An object or Role containing the properties to set * @arg {Number} [options.color] The hex color of the role, in number form (ex: 0x3d15b3 or 4040115) + * @arg {Object} [options.colors] The role's colors + * @arg {Number} [options.colors.primaryColor] The primary color of the role + * @arg {Number?} [options.colors.secondaryColor] The secondary color of the role (for gradient roles) + * @arg {Number?} [options.colors.tertiaryColor] The tertiary color of the role (for holographic roles) * @arg {Boolean} [options.hoist] Whether to hoist the role in the user list or not * @arg {String} [options.icon] The role icon as a base64 data URI * @arg {Boolean} [options.mentionable] Whether the role is mentionable or not @@ -911,6 +915,10 @@ class Guild extends Base { * @arg {String} roleID The ID of the role * @arg {Object} options The properties to edit * @arg {Number} [options.color] The hex color of the role, in number form (ex: 0x3da5b3 or 4040115) + * @arg {Object} [options.colors] The role's colors + * @arg {Number} [options.colors.primaryColor] The primary color of the role + * @arg {Number?} [options.colors.secondaryColor] The secondary color of the role (for gradient roles) + * @arg {Number?} [options.colors.tertiaryColor] The tertiary color of the role (for holographic roles) * @arg {Boolean} [options.hoist] Whether to hoist the role in the user list or not * @arg {String} [options.icon] The role icon as a base64 data URI * @arg {Boolean} [options.mentionable] Whether the role is mentionable or not diff --git a/lib/structures/Role.js b/lib/structures/Role.js index 18706f5b7..e40fc1ca3 100644 --- a/lib/structures/Role.js +++ b/lib/structures/Role.js @@ -7,6 +7,10 @@ const Permission = require("./Permission"); /** * Represents a role * @prop {Number} color The hex color of the role in base 10 + * @prop {Object} colors The role's colors + * @prop {Number} colors.primaryColor The primary color of the role + * @prop {Number?} colors.secondaryColor The secondary color of the role (for gradient roles) + * @prop {Number?} colors.tertiaryColor The tertiary color of the role (for holographic roles) * @prop {Number} createdAt Timestamp of the role's creation * @prop {Number} flags The flags of the role (see constants) * @prop {Guild} guild The guild that owns the role @@ -53,6 +57,13 @@ class Role extends Base { if (data.color !== undefined) { this.color = data.color; } + if (data.colors !== undefined) { + this.colors = { + primaryColor: data.colors.primary_color, + secondaryColor: data.colors.secondary_color, + tertiaryColor: data.colors.tertiary_color, + }; + } if (data.position !== undefined) { this.position = data.position; } @@ -105,6 +116,10 @@ class Role extends Base { * Edit the guild role * @arg {Object} options The properties to edit * @arg {Number} [options.color] The hex color of the role, in number form (ex: 0x3da5b3 or 4040115) + * @arg {Object} [options.colors] The role's colors + * @arg {Number} [options.colors.primaryColor] The primary color of the role + * @arg {Number?} [options.colors.secondaryColor] The secondary color of the role (for gradient roles) + * @arg {Number?} [options.colors.tertiaryColor] The tertiary color of the role (for holographic roles) * @arg {Boolean} [options.hoist] Whether to hoist the role in the user list or not * @arg {String} [options.icon] The role icon as a base64 data URI * @arg {Boolean} [options.mentionable] Whether the role is mentionable or not @@ -130,6 +145,7 @@ class Role extends Base { toJSON(props = []) { return super.toJSON([ "color", + "colors", "hoist", "icon", "managed",