Skip to content

Commit 370fb31

Browse files
committed
refactor(Role)!: remove color
1 parent 95c116a commit 370fb31

File tree

4 files changed

+5
-39
lines changed

4 files changed

+5
-39
lines changed

packages/discord.js/src/managers/GuildMemberRoleManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class GuildMemberRoleManager extends DataManager {
7272
* @readonly
7373
*/
7474
get color() {
75-
const coloredRoles = this.cache.filter(role => role.color);
75+
const coloredRoles = this.cache.filter(role => role.colors.primaryColor);
7676
if (!coloredRoles.size) return null;
7777
return coloredRoles.reduce((prev, role) => (role.comparePositionTo(prev) > 0 ? role : prev));
7878
}

packages/discord.js/src/managers/RoleManager.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ class RoleManager extends CachedManager {
123123
*
124124
* @typedef {Object} RoleCreateOptions
125125
* @property {string} [name] The name of the new role
126-
* @property {ColorResolvable} [color] The color to create the role with.
127-
* This will still be returned by the API, but using the `colors` field is recommended when doing requests
128126
* @property {RoleColors} [colors] The colors to create the role with
129127
* @property {boolean} [hoist] Whether or not the new role should be hoisted
130128
* @property {PermissionResolvable} [permissions] The permissions for the new role
@@ -152,16 +150,17 @@ class RoleManager extends CachedManager {
152150
* // Create a new role with data and a reason
153151
* guild.roles.create({
154152
* name: 'Super Cool Blue People',
155-
* color: Colors.Blue,
156153
* reason: 'we needed a role for Super Cool People',
154+
* colors: {
155+
* primaryColor: Colors.Blue,
156+
* },
157157
* })
158158
* .then(console.log)
159159
* .catch(console.error);
160160
*/
161161
async create(options = {}) {
162-
let { color, permissions, icon } = options;
162+
let { permissions, icon } = options;
163163
const { name, hoist, position, mentionable, reason, unicodeEmoji } = options;
164-
color &&= resolveColor(color);
165164
if (permissions !== undefined) permissions = new PermissionsBitField(permissions);
166165
if (icon) {
167166
const guildEmojiURL = this.guild.emojis.resolve(icon)?.imageURL();
@@ -178,7 +177,6 @@ class RoleManager extends CachedManager {
178177
const data = await this.client.rest.post(Routes.guildRoles(this.guild.id), {
179178
body: {
180179
name,
181-
color,
182180
colors,
183181
hoist,
184182
permissions,
@@ -238,7 +236,6 @@ class RoleManager extends CachedManager {
238236

239237
const body = {
240238
name: options.name,
241-
color: options.color === undefined ? undefined : resolveColor(options.color),
242239
colors,
243240
hoist: options.hoist,
244241
permissions: options.permissions === undefined ? undefined : new PermissionsBitField(options.permissions),

packages/discord.js/src/structures/Role.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ class Role extends Base {
5757
this.name = data.name;
5858
}
5959

60-
if ('color' in data) {
61-
/**
62-
* The base 10 color of the role
63-
*
64-
* @type {number}
65-
*/
66-
this.color = data.color;
67-
}
68-
6960
if ('colors' in data) {
7061
/**
7162
* The colors of the role
@@ -270,8 +261,6 @@ class Role extends Base {
270261
*
271262
* @typedef {Object} RoleData
272263
* @property {string} [name] The name of the role
273-
* @property {ColorResolvable} [color] The color of the role, either a hex string or a base 10 number.
274-
* This will still be returned by the API, but using the `colors` field is recommended when doing requests
275264
* @property {RoleColors} [colors] The colors of the role
276265
* @property {boolean} [hoist] Whether or not the role should be hoisted
277266
* @property {number} [position] The position of the role
@@ -329,22 +318,6 @@ class Role extends Base {
329318
return this.edit({ name, reason });
330319
}
331320

332-
/**
333-
* Sets a new color for the role.
334-
*
335-
* @param {ColorResolvable} color The color of the role
336-
* @param {string} [reason] Reason for changing the role's color
337-
* @returns {Promise<Role>}
338-
* @example
339-
* // Set the color of a role
340-
* role.setColor('#FF0000')
341-
* .then(updated => console.log(`Set color of role to ${updated.color}`))
342-
* .catch(console.error);
343-
*/
344-
async setColor(color, reason) {
345-
return this.edit({ color, reason });
346-
}
347-
348321
/**
349322
* Sets new colors for the role.
350323
*
@@ -506,7 +479,6 @@ class Role extends Base {
506479
role &&
507480
this.id === role.id &&
508481
this.name === role.name &&
509-
this.color === role.color &&
510482
this.colors.primaryColor === role.colors.primaryColor &&
511483
this.colors.secondaryColor === role.colors.secondaryColor &&
512484
this.colors.tertiaryColor === role.colors.tertiaryColor &&

packages/discord.js/typings/index.d.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2842,7 +2842,6 @@ export interface RoleColors {
28422842

28432843
export class Role extends Base {
28442844
private constructor(client: Client<true>, data: APIRole, guild: Guild);
2845-
public color: number;
28462845
public colors: RoleColors;
28472846
public get createdAt(): Date;
28482847
public get createdTimestamp(): number;
@@ -2871,7 +2870,6 @@ export class Role extends Base {
28712870
channel: NonThreadGuildBasedChannel | Snowflake,
28722871
checkAdmin?: boolean,
28732872
): Readonly<PermissionsBitField>;
2874-
public setColor(color: ColorResolvable, reason?: string): Promise<Role>;
28752873
public setColors(colors: RoleColors, reason?: string): Promise<Role>;
28762874
public setHoist(hoist?: boolean, reason?: string): Promise<Role>;
28772875
public setMentionable(mentionable?: boolean, reason?: string): Promise<Role>;
@@ -6805,7 +6803,6 @@ export interface ResolvedOverwriteOptions {
68056803
}
68066804

68076805
export interface RoleData {
6808-
color?: ColorResolvable;
68096806
colors?: RoleColors;
68106807
hoist?: boolean;
68116808
icon?: Base64Resolvable | BufferResolvable | EmojiResolvable | null;

0 commit comments

Comments
 (0)