Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ declare namespace Eris {
}
interface OldRole {
color: number;
colors: RoleColors;
flags: number;
hoist: boolean;
icon: string | null;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -3268,6 +3275,7 @@ declare namespace Eris {

export class Role extends Base {
color: number;
colors: RoleColors;
createdAt: number;
flags: number;
guild: Guild;
Expand Down
20 changes: 20 additions & 0 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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)));
}

Expand Down
1 change: 1 addition & 0 deletions lib/Constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export default interface Constants {
"CREATOR_STORE_PAGE",
"DEVELOPER_SUPPORT_SERVER",
"DISCOVERABLE",
"ENHANCED_ROLE_COLORS",
"FEATURABLE",
"INVITES_DISABLED",
"INVITE_SPLASH",
Expand Down
1 change: 1 addition & 0 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ module.exports.GuildFeatures = [
"CREATOR_STORE_PAGE",
"DEVELOPER_SUPPORT_SERVER",
"DISCOVERABLE",
"ENHANCED_ROLE_COLORS",
"FEATURABLE",
"INVITE_SPLASH",
"INVITES_DISABLED",
Expand Down
5 changes: 5 additions & 0 deletions lib/gateway/Shard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions lib/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions lib/structures/Role.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -130,6 +145,7 @@ class Role extends Base {
toJSON(props = []) {
return super.toJSON([
"color",
"colors",
"hoist",
"icon",
"managed",
Expand Down