discord.js 15.0.0-dev.1752020077-bc6005f44 → 15.0.0-dev.1752192883-35cc57ab9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "discord.js",
4
- "version": "15.0.0-dev.1752020077-bc6005f44",
4
+ "version": "15.0.0-dev.1752192883-35cc57ab9",
5
5
  "description": "A powerful library for interacting with the Discord API",
6
6
  "main": "./src/index.js",
7
7
  "types": "./typings/index.d.ts",
@@ -61,9 +61,9 @@
61
61
  "magic-bytes.js": "^1.10.0",
62
62
  "tslib": "^2.8.1",
63
63
  "undici": "7.8.0",
64
- "@discordjs/builders": "^1.11.1",
65
- "@discordjs/collection": "^2.1.1",
66
64
  "@discordjs/formatters": "^0.6.1",
65
+ "@discordjs/collection": "^2.1.1",
66
+ "@discordjs/builders": "^1.11.1",
67
67
  "@discordjs/rest": "^2.5.0",
68
68
  "@discordjs/util": "^1.1.1",
69
69
  "@discordjs/ws": "^2.0.2"
@@ -84,8 +84,8 @@
84
84
  "turbo": "^2.5.2",
85
85
  "typescript": "~5.8.3",
86
86
  "@discordjs/api-extractor": "^7.52.7",
87
- "@discordjs/scripts": "^0.1.0",
88
- "@discordjs/docgen": "^0.12.1"
87
+ "@discordjs/docgen": "^0.12.1",
88
+ "@discordjs/scripts": "^0.1.0"
89
89
  },
90
90
  "engines": {
91
91
  "node": ">=22.12.0"
@@ -72,7 +72,7 @@ class GuildMemberRoleManager extends DataManager {
72
72
  * @readonly
73
73
  */
74
74
  get color() {
75
- const coloredRoles = this.cache.filter(role => role.color);
75
+ const coloredRoles = this.cache.filter(role => role.colors.primaryColor);
76
76
  if (!coloredRoles.size) return null;
77
77
  return coloredRoles.reduce((prev, role) => (role.comparePositionTo(prev) > 0 ? role : prev));
78
78
  }
@@ -109,12 +109,22 @@ class RoleManager extends CachedManager {
109
109
  * @returns {?Snowflake}
110
110
  */
111
111
 
112
+ /**
113
+ * @typedef {Object} RoleColorsResolvable
114
+ * @property {ColorResolvable} primaryColor The primary color of the role
115
+ * @property {ColorResolvable} [secondaryColor] The secondary color of the role.
116
+ * This will make the role a gradient between the other provided colors
117
+ * @property {ColorResolvable} [tertiaryColor] The tertiary color of the role.
118
+ * When sending `tertiaryColor` the API enforces the role color to be a holographic style with values of `primaryColor = 11127295`, `secondaryColor = 16759788`, and `tertiaryColor = 16761760`.
119
+ * These values are available as a constant: `Constants.HolographicStyle`
120
+ */
121
+
112
122
  /**
113
123
  * Options used to create a new role.
114
124
  *
115
125
  * @typedef {Object} RoleCreateOptions
116
126
  * @property {string} [name] The name of the new role
117
- * @property {ColorResolvable} [color] The data to create the role with
127
+ * @property {RoleColorsResolvable} [colors] The colors to create the role with
118
128
  * @property {boolean} [hoist] Whether or not the new role should be hoisted
119
129
  * @property {PermissionResolvable} [permissions] The permissions for the new role
120
130
  * @property {number} [position] The position of the new role
@@ -141,16 +151,30 @@ class RoleManager extends CachedManager {
141
151
  * // Create a new role with data and a reason
142
152
  * guild.roles.create({
143
153
  * name: 'Super Cool Blue People',
144
- * color: Colors.Blue,
145
154
  * reason: 'we needed a role for Super Cool People',
155
+ * colors: {
156
+ * primaryColor: Colors.Blue,
157
+ * },
158
+ * })
159
+ * .then(console.log)
160
+ * .catch(console.error);
161
+ * @example
162
+ * // Create a role with holographic colors
163
+ * guild.roles.create({
164
+ * name: 'Holographic Role',
165
+ * reason: 'Creating a role with holographic effect',
166
+ * colors: {
167
+ * primaryColor: Constants.HolographicStyle.Primary,
168
+ * secondaryColor: Constants.HolographicStyle.Secondary,
169
+ * tertiaryColor: Constants.HolographicStyle.Tertiary,
170
+ * },
146
171
  * })
147
172
  * .then(console.log)
148
173
  * .catch(console.error);
149
174
  */
150
175
  async create(options = {}) {
151
- let { color, permissions, icon } = options;
176
+ let { permissions, icon } = options;
152
177
  const { name, hoist, position, mentionable, reason, unicodeEmoji } = options;
153
- color &&= resolveColor(color);
154
178
  if (permissions !== undefined) permissions = new PermissionsBitField(permissions);
155
179
  if (icon) {
156
180
  const guildEmojiURL = this.guild.emojis.resolve(icon)?.imageURL();
@@ -158,10 +182,16 @@ class RoleManager extends CachedManager {
158
182
  if (typeof icon !== 'string') icon = undefined;
159
183
  }
160
184
 
185
+ const colors = options.colors && {
186
+ primary_color: resolveColor(options.colors.primaryColor),
187
+ secondary_color: options.colors.secondaryColor && resolveColor(options.colors.secondaryColor),
188
+ tertiary_color: options.colors.tertiaryColor && resolveColor(options.colors.tertiaryColor),
189
+ };
190
+
161
191
  const data = await this.client.rest.post(Routes.guildRoles(this.guild.id), {
162
192
  body: {
163
193
  name,
164
- color,
194
+ colors,
165
195
  hoist,
166
196
  permissions,
167
197
  mentionable,
@@ -212,9 +242,15 @@ class RoleManager extends CachedManager {
212
242
  if (typeof icon !== 'string') icon = undefined;
213
243
  }
214
244
 
245
+ const colors = options.colors && {
246
+ primary_color: resolveColor(options.colors.primaryColor),
247
+ secondary_color: options.colors.secondaryColor && resolveColor(options.colors.secondaryColor),
248
+ tertiary_color: options.colors.tertiaryColor && resolveColor(options.colors.tertiaryColor),
249
+ };
250
+
215
251
  const body = {
216
252
  name: options.name,
217
- color: options.color === undefined ? undefined : resolveColor(options.color),
253
+ colors,
218
254
  hoist: options.hoist,
219
255
  permissions: options.permissions === undefined ? undefined : new PermissionsBitField(options.permissions),
220
256
  mentionable: options.mentionable,
@@ -57,13 +57,27 @@ class Role extends Base {
57
57
  this.name = data.name;
58
58
  }
59
59
 
60
- if ('color' in data) {
60
+ /**
61
+ * @typedef {Object} RoleColors
62
+ * @property {number} primaryColor The primary color of the role
63
+ * @property {?number} secondaryColor The secondary color of the role.
64
+ * This will make the role a gradient between the other provided colors
65
+ * @property {?number} tertiaryColor The tertiary color of the role.
66
+ * When sending `tertiaryColor` the API enforces the role color to be a holographic style with values of `primaryColor = 11127295`, `secondaryColor = 16759788`, and `tertiaryColor = 16761760`.
67
+ * These values are available as a constant: `Constants.HolographicStyle`
68
+ */
69
+
70
+ if ('colors' in data) {
61
71
  /**
62
- * The base 10 color of the role
72
+ * The colors of the role
63
73
  *
64
- * @type {number}
74
+ * @type {RoleColors}
65
75
  */
66
- this.color = data.color;
76
+ this.colors = {
77
+ primaryColor: data.colors.primary_color,
78
+ secondaryColor: data.colors.secondary_color,
79
+ tertiaryColor: data.colors.tertiary_color,
80
+ };
67
81
  }
68
82
 
69
83
  if ('hoist' in data) {
@@ -257,7 +271,7 @@ class Role extends Base {
257
271
  *
258
272
  * @typedef {Object} RoleData
259
273
  * @property {string} [name] The name of the role
260
- * @property {ColorResolvable} [color] The color of the role, either a hex string or a base 10 number
274
+ * @property {RoleColorsResolvable} [colors] The colors of the role
261
275
  * @property {boolean} [hoist] Whether or not the role should be hoisted
262
276
  * @property {number} [position] The position of the role
263
277
  * @property {PermissionResolvable} [permissions] The permissions of the role
@@ -315,19 +329,28 @@ class Role extends Base {
315
329
  }
316
330
 
317
331
  /**
318
- * Sets a new color for the role.
332
+ * Sets new colors for the role.
319
333
  *
320
- * @param {ColorResolvable} color The color of the role
321
- * @param {string} [reason] Reason for changing the role's color
334
+ * @param {RoleColorsResolvable} colors The colors of the role
335
+ * @param {string} [reason] Reason for changing the role's colors
322
336
  * @returns {Promise<Role>}
323
337
  * @example
324
- * // Set the color of a role
325
- * role.setColor('#FF0000')
326
- * .then(updated => console.log(`Set color of role to ${updated.color}`))
338
+ * // Set the colors of a role
339
+ * role.setColors({ primaryColor: '#FF0000', secondaryColor: '#00FF00', tertiaryColor: '#0000FF' })
340
+ * .then(updated => console.log(`Set colors of role to ${updated.colors}`))
341
+ * .catch(console.error);
342
+ * @example
343
+ * // Set holographic colors using constants
344
+ * role.setColors({
345
+ * primaryColor: Constants.HolographicStyle.Primary,
346
+ * secondaryColor: Constants.HolographicStyle.Secondary,
347
+ * tertiaryColor: Constants.HolographicStyle.Tertiary,
348
+ * })
349
+ * .then(updated => console.log(`Set holographic colors for role ${updated.name}`))
327
350
  * .catch(console.error);
328
351
  */
329
- async setColor(color, reason) {
330
- return this.edit({ color, reason });
352
+ async setColors(colors, reason) {
353
+ return this.edit({ colors, reason });
331
354
  }
332
355
 
333
356
  /**
@@ -475,7 +498,9 @@ class Role extends Base {
475
498
  role &&
476
499
  this.id === role.id &&
477
500
  this.name === role.name &&
478
- this.color === role.color &&
501
+ this.colors.primaryColor === role.colors.primaryColor &&
502
+ this.colors.secondaryColor === role.colors.secondaryColor &&
503
+ this.colors.tertiaryColor === role.colors.tertiaryColor &&
479
504
  this.hoist === role.hoist &&
480
505
  this.position === role.position &&
481
506
  this.permissions.bitfield === role.permissions.bitfield &&
@@ -222,6 +222,21 @@ exports.StickerFormatExtensionMap = {
222
222
  [StickerFormatType.GIF]: ImageFormat.GIF,
223
223
  };
224
224
 
225
+ /**
226
+ * Holographic color values for role styling.
227
+ * When using `tertiaryColor`, the API enforces these specific values for holographic effect.
228
+ *
229
+ * @typedef {Object} HolographicStyle
230
+ * @property {number} Primary 11127295 (0xA9FFFF)
231
+ * @property {number} Secondary 16759788 (0xFFCCCC)
232
+ * @property {number} Tertiary 16761760 (0xFFE0A0)
233
+ */
234
+ exports.HolographicStyle = {
235
+ Primary: 11_127_295,
236
+ Secondary: 16_759_788,
237
+ Tertiary: 16_761_760,
238
+ };
239
+
225
240
  /**
226
241
  * @typedef {Object} Constants Constants that can be used in an enum or object-like way.
227
242
  * @property {number} MaxBulkDeletableMessageAge Max bulk deletable message age
@@ -232,4 +247,5 @@ exports.StickerFormatExtensionMap = {
232
247
  * @property {VoiceBasedChannelTypes} VoiceBasedChannelTypes The types of channels that are voice-based
233
248
  * @property {SelectMenuTypes} SelectMenuTypes The types of components that are select menus.
234
249
  * @property {Object} StickerFormatExtensionMap A mapping between sticker formats and their respective image formats.
250
+ * @property {HolographicStyle} HolographicStyle Holographic color values for role styling.
235
251
  */
@@ -2823,9 +2823,21 @@ export class RichPresenceAssets {
2823
2823
  public smallImageURL(options?: ImageURLOptions): string | null;
2824
2824
  }
2825
2825
 
2826
+ export interface RoleColors {
2827
+ primaryColor: number;
2828
+ secondaryColor: number | null;
2829
+ tertiaryColor: number | null;
2830
+ }
2831
+
2832
+ export interface RoleColorsResolvable {
2833
+ primaryColor: ColorResolvable;
2834
+ secondaryColor?: ColorResolvable;
2835
+ tertiaryColor?: ColorResolvable;
2836
+ }
2837
+
2826
2838
  export class Role extends Base {
2827
2839
  private constructor(client: Client<true>, data: APIRole, guild: Guild);
2828
- public color: number;
2840
+ public colors: RoleColors;
2829
2841
  public get createdAt(): Date;
2830
2842
  public get createdTimestamp(): number;
2831
2843
  public get editable(): boolean;
@@ -2853,7 +2865,7 @@ export class Role extends Base {
2853
2865
  channel: NonThreadGuildBasedChannel | Snowflake,
2854
2866
  checkAdmin?: boolean,
2855
2867
  ): Readonly<PermissionsBitField>;
2856
- public setColor(color: ColorResolvable, reason?: string): Promise<Role>;
2868
+ public setColors(colors: RoleColorsResolvable, reason?: string): Promise<Role>;
2857
2869
  public setHoist(hoist?: boolean, reason?: string): Promise<Role>;
2858
2870
  public setMentionable(mentionable?: boolean, reason?: string): Promise<Role>;
2859
2871
  public setName(name: string, reason?: string): Promise<Role>;
@@ -3808,6 +3820,11 @@ export type UndeletableMessageType =
3808
3820
 
3809
3821
  export const Constants: {
3810
3822
  GuildTextBasedChannelTypes: GuildTextBasedChannelTypes[];
3823
+ HolographicStyle: {
3824
+ Primary: 11_127_295;
3825
+ Secondary: 16_759_788;
3826
+ Tertiary: 16_761_760;
3827
+ };
3811
3828
  MaxBulkDeletableMessageAge: 1_209_600_000;
3812
3829
  NonSystemMessageTypes: NonSystemMessageType[];
3813
3830
  SelectMenuTypes: SelectMenuType[];
@@ -6836,7 +6853,7 @@ export interface ResolvedOverwriteOptions {
6836
6853
  }
6837
6854
 
6838
6855
  export interface RoleData {
6839
- color?: ColorResolvable;
6856
+ colors?: RoleColorsResolvable;
6840
6857
  hoist?: boolean;
6841
6858
  icon?: Base64Resolvable | BufferResolvable | EmojiResolvable | null;
6842
6859
  mentionable?: boolean;
@@ -2823,9 +2823,21 @@ export class RichPresenceAssets {
2823
2823
  public smallImageURL(options?: ImageURLOptions): string | null;
2824
2824
  }
2825
2825
 
2826
+ export interface RoleColors {
2827
+ primaryColor: number;
2828
+ secondaryColor: number | null;
2829
+ tertiaryColor: number | null;
2830
+ }
2831
+
2832
+ export interface RoleColorsResolvable {
2833
+ primaryColor: ColorResolvable;
2834
+ secondaryColor?: ColorResolvable;
2835
+ tertiaryColor?: ColorResolvable;
2836
+ }
2837
+
2826
2838
  export class Role extends Base {
2827
2839
  private constructor(client: Client<true>, data: APIRole, guild: Guild);
2828
- public color: number;
2840
+ public colors: RoleColors;
2829
2841
  public get createdAt(): Date;
2830
2842
  public get createdTimestamp(): number;
2831
2843
  public get editable(): boolean;
@@ -2853,7 +2865,7 @@ export class Role extends Base {
2853
2865
  channel: NonThreadGuildBasedChannel | Snowflake,
2854
2866
  checkAdmin?: boolean,
2855
2867
  ): Readonly<PermissionsBitField>;
2856
- public setColor(color: ColorResolvable, reason?: string): Promise<Role>;
2868
+ public setColors(colors: RoleColorsResolvable, reason?: string): Promise<Role>;
2857
2869
  public setHoist(hoist?: boolean, reason?: string): Promise<Role>;
2858
2870
  public setMentionable(mentionable?: boolean, reason?: string): Promise<Role>;
2859
2871
  public setName(name: string, reason?: string): Promise<Role>;
@@ -3808,6 +3820,11 @@ export type UndeletableMessageType =
3808
3820
 
3809
3821
  export const Constants: {
3810
3822
  GuildTextBasedChannelTypes: GuildTextBasedChannelTypes[];
3823
+ HolographicStyle: {
3824
+ Primary: 11_127_295;
3825
+ Secondary: 16_759_788;
3826
+ Tertiary: 16_761_760;
3827
+ };
3811
3828
  MaxBulkDeletableMessageAge: 1_209_600_000;
3812
3829
  NonSystemMessageTypes: NonSystemMessageType[];
3813
3830
  SelectMenuTypes: SelectMenuType[];
@@ -6836,7 +6853,7 @@ export interface ResolvedOverwriteOptions {
6836
6853
  }
6837
6854
 
6838
6855
  export interface RoleData {
6839
- color?: ColorResolvable;
6856
+ colors?: RoleColorsResolvable;
6840
6857
  hoist?: boolean;
6841
6858
  icon?: Base64Resolvable | BufferResolvable | EmojiResolvable | null;
6842
6859
  mentionable?: boolean;