discord.js 15.0.0-dev.1752452150-7e3d4e536 → 15.0.0-dev.1752624900-d03cacbde

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.1752452150-7e3d4e536",
4
+ "version": "15.0.0-dev.1752624900-d03cacbde",
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,12 +61,12 @@
61
61
  "magic-bytes.js": "^1.12.1",
62
62
  "tslib": "^2.8.1",
63
63
  "undici": "7.11.0",
64
- "@discordjs/collection": "^2.1.1",
65
64
  "@discordjs/builders": "^1.11.1",
66
- "@discordjs/util": "^1.1.1",
67
65
  "@discordjs/formatters": "^0.6.1",
68
- "@discordjs/ws": "^2.0.2",
69
- "@discordjs/rest": "^2.5.0"
66
+ "@discordjs/collection": "^2.1.1",
67
+ "@discordjs/rest": "^2.5.0",
68
+ "@discordjs/util": "^1.1.1",
69
+ "@discordjs/ws": "^2.0.2"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@favware/cliff-jumper": "^4.1.0",
@@ -123,24 +123,63 @@ class MessageManager extends CachedManager {
123
123
  return data.reduce((_data, message) => _data.set(message.id, this._add(message, options.cache)), new Collection());
124
124
  }
125
125
 
126
+ /**
127
+ * Options used to fetch pinned messages.
128
+ *
129
+ * @typedef {Object} FetchPinnedMessagesOptions
130
+ * @property {DateResolvable} [before] Consider only pinned messages before this time
131
+ * @property {number} [limit] The maximum number of pinned messages to return
132
+ * @property {boolean} [cache] Whether to cache the pinned messages
133
+ */
134
+
135
+ /**
136
+ * Data returned from fetching pinned messages.
137
+ *
138
+ * @typedef {Object} FetchPinnedMessagesResponse
139
+ * @property {MessagePin[]} items The pinned messages
140
+ * @property {boolean} hasMore Whether there are additional pinned messages that require a subsequent call
141
+ */
142
+
143
+ /**
144
+ * Pinned message data returned from fetching pinned messages.
145
+ *
146
+ * @typedef {Object} MessagePin
147
+ * @property {Date} pinnedAt The time the message was pinned at
148
+ * @property {number} pinnedTimestamp The timestamp the message was pinned at
149
+ * @property {Message} message The pinned message
150
+ */
151
+
126
152
  /**
127
153
  * Fetches the pinned messages of this channel and returns a collection of them.
128
154
  * <info>The returned Collection does not contain any reaction data of the messages.
129
155
  * Those need to be fetched separately.</info>
130
156
  *
131
- * @param {boolean} [cache=true] Whether to cache the message(s)
132
- * @returns {Promise<Collection<Snowflake, Message>>}
157
+ * @param {FetchPinnedMessagesOptions} [options={}] Options for fetching pinned messages
158
+ * @returns {Promise<FetchPinnedMessagesResponse>}
133
159
  * @example
134
160
  * // Get pinned messages
135
- * channel.messages.fetchPinned()
136
- * .then(messages => console.log(`Received ${messages.size} messages`))
161
+ * channel.messages.fetchPins()
162
+ * .then(messages => console.log(`Received ${messages.items.length} messages`))
137
163
  * .catch(console.error);
138
164
  */
139
- async fetchPinned(cache = true) {
140
- const data = await this.client.rest.get(Routes.channelPins(this.channel.id));
141
- const messages = new Collection();
142
- for (const message of data) messages.set(message.id, this._add(message, cache));
143
- return messages;
165
+ async fetchPins(options = {}) {
166
+ const data = await this.client.rest.get(Routes.channelMessagesPins(this.channel.id), {
167
+ query: makeURLSearchParams({
168
+ ...options,
169
+ before: options.before && new Date(options.before).toISOString(),
170
+ }),
171
+ });
172
+
173
+ return {
174
+ items: data.items.map(item => ({
175
+ pinnedTimestamp: Date.parse(item.pinned_at),
176
+ get pinnedAt() {
177
+ return new Date(this.pinnedTimestamp);
178
+ },
179
+ message: this._add(item.message, options.cache),
180
+ })),
181
+ hasMore: data.has_more,
182
+ };
144
183
  }
145
184
 
146
185
  /**
@@ -221,7 +260,7 @@ class MessageManager extends CachedManager {
221
260
  const messageId = this.resolveId(message);
222
261
  if (!messageId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'message', 'MessageResolvable');
223
262
 
224
- await this.client.rest.put(Routes.channelPin(this.channel.id, messageId), { reason });
263
+ await this.client.rest.put(Routes.channelMessagesPin(this.channel.id, messageId), { reason });
225
264
  }
226
265
 
227
266
  /**
@@ -235,7 +274,7 @@ class MessageManager extends CachedManager {
235
274
  const messageId = this.resolveId(message);
236
275
  if (!messageId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'message', 'MessageResolvable');
237
276
 
238
- await this.client.rest.delete(Routes.channelPin(this.channel.id, messageId), { reason });
277
+ await this.client.rest.delete(Routes.channelMessagesPin(this.channel.id, messageId), { reason });
239
278
  }
240
279
 
241
280
  /**
@@ -3,6 +3,7 @@
3
3
  const { userMention } = require('@discordjs/formatters');
4
4
  const { calculateUserDefaultAvatarIndex } = require('@discordjs/rest');
5
5
  const { DiscordSnowflake } = require('@sapphire/snowflake');
6
+ const { _transformCollectibles } = require('../util/Transformers.js');
6
7
  const { UserFlagsBitField } = require('../util/UserFlagsBitField.js');
7
8
  const { Base } = require('./Base.js');
8
9
 
@@ -151,6 +152,30 @@ class User extends Base {
151
152
  } else {
152
153
  this.avatarDecorationData = null;
153
154
  }
155
+
156
+ /**
157
+ * @typedef {Object} NameplateData
158
+ * @property {Snowflake} skuId The id of the nameplate's SKU
159
+ * @property {string} asset The nameplate's asset path
160
+ * @property {string} label The nameplate's label
161
+ * @property {NameplatePalette} palette Background color of the nameplate
162
+ */
163
+
164
+ /**
165
+ * @typedef {Object} Collectibles
166
+ * @property {?NameplateData} nameplate The user's nameplate data
167
+ */
168
+
169
+ if (data.collectibles) {
170
+ /**
171
+ * The user's collectibles
172
+ *
173
+ * @type {?Collectibles}
174
+ */
175
+ this.collectibles = _transformCollectibles(data.collectibles);
176
+ } else {
177
+ this.collectibles = null;
178
+ }
154
179
  }
155
180
 
156
181
  /**
@@ -338,7 +363,11 @@ class User extends Base {
338
363
  this.banner === user.banner &&
339
364
  this.accentColor === user.accentColor &&
340
365
  this.avatarDecorationData?.asset === user.avatarDecorationData?.asset &&
341
- this.avatarDecorationData?.skuId === user.avatarDecorationData?.skuId
366
+ this.avatarDecorationData?.skuId === user.avatarDecorationData?.skuId &&
367
+ this.collectibles?.nameplate?.skuId === user.collectibles?.nameplate?.skuId &&
368
+ this.collectibles?.nameplate?.asset === user.collectibles?.nameplate?.asset &&
369
+ this.collectibles?.nameplate?.label === user.collectibles?.nameplate?.label &&
370
+ this.collectibles?.nameplate?.palette === user.collectibles?.nameplate?.palette
342
371
  );
343
372
  }
344
373
 
@@ -363,6 +392,12 @@ class User extends Base {
363
392
  ('avatar_decoration_data' in user
364
393
  ? this.avatarDecorationData?.asset === user.avatar_decoration_data?.asset &&
365
394
  this.avatarDecorationData?.skuId === user.avatar_decoration_data?.sku_id
395
+ : true) &&
396
+ ('collectibles' in user
397
+ ? this.collectibles?.nameplate?.skuId === user.collectibles?.nameplate?.sku_id &&
398
+ this.collectibles?.nameplate?.asset === user.collectibles?.nameplate?.asset &&
399
+ this.collectibles?.nameplate?.label === user.collectibles?.nameplate?.label &&
400
+ this.collectibles?.nameplate?.palette === user.collectibles?.nameplate?.palette
366
401
  : true)
367
402
  );
368
403
  }
@@ -549,6 +549,11 @@
549
549
  * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/MessageFlags}
550
550
  */
551
551
 
552
+ /**
553
+ * @external NameplatePalette
554
+ * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/NameplatePalette}
555
+ */
556
+
552
557
  /**
553
558
  * @external OAuth2Scopes
554
559
  * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/OAuth2Scopes}
@@ -92,8 +92,29 @@ function _transformAPIIncidentsData(data) {
92
92
  };
93
93
  }
94
94
 
95
+ /**
96
+ * Transforms a collectibles object to a camel-cased variant.
97
+ *
98
+ * @param {APICollectibles} collectibles The collectibles to transform
99
+ * @returns {Collectibles}
100
+ * @ignore
101
+ */
102
+ function _transformCollectibles(collectibles) {
103
+ if (!collectibles.nameplate) return { nameplate: null };
104
+
105
+ return {
106
+ nameplate: {
107
+ skuId: collectibles.nameplate.sku_id,
108
+ asset: collectibles.nameplate.asset,
109
+ label: collectibles.nameplate.label,
110
+ palette: collectibles.nameplate.palette,
111
+ },
112
+ };
113
+ }
114
+
95
115
  exports.toSnakeCase = toSnakeCase;
96
116
  exports._transformAPIAutoModerationAction = _transformAPIAutoModerationAction;
97
117
  exports._transformAPIMessageInteractionMetadata = _transformAPIMessageInteractionMetadata;
98
118
  exports._transformGuildScheduledEventRecurrenceRule = _transformGuildScheduledEventRecurrenceRule;
99
119
  exports._transformAPIIncidentsData = _transformAPIIncidentsData;
120
+ exports._transformCollectibles = _transformCollectibles;
@@ -170,6 +170,7 @@ import {
170
170
  MessageFlags,
171
171
  MessageReferenceType,
172
172
  MessageType,
173
+ NameplatePalette,
173
174
  OAuth2Scopes,
174
175
  OverwriteType,
175
176
  PermissionFlagsBits,
@@ -3509,6 +3510,17 @@ export interface AvatarDecorationData {
3509
3510
  skuId: Snowflake;
3510
3511
  }
3511
3512
 
3513
+ export interface NameplateData {
3514
+ asset: string;
3515
+ label: string;
3516
+ palette: NameplatePalette;
3517
+ skuId: Snowflake;
3518
+ }
3519
+
3520
+ export interface Collectibles {
3521
+ nameplate: NameplateData | null;
3522
+ }
3523
+
3512
3524
  export interface UnfurledMediaItemData {
3513
3525
  url: string;
3514
3526
  }
@@ -3531,6 +3543,7 @@ export class User extends Base {
3531
3543
  public bot: boolean;
3532
3544
  public get createdAt(): Date;
3533
3545
  public get createdTimestamp(): number;
3546
+ public collectibles: Collectibles | null;
3534
3547
  public discriminator: string;
3535
3548
  public get displayName(): string;
3536
3549
  public get defaultAvatarURL(): string;
@@ -4503,7 +4516,7 @@ export abstract class MessageManager<InGuild extends boolean = boolean> extends
4503
4516
  ): Promise<Message<InGuild>>;
4504
4517
  public fetch(options: FetchMessageOptions | MessageResolvable): Promise<Message<InGuild>>;
4505
4518
  public fetch(options?: FetchMessagesOptions): Promise<Collection<Snowflake, Message<InGuild>>>;
4506
- public fetchPinned(cache?: boolean): Promise<Collection<Snowflake, Message<InGuild>>>;
4519
+ public fetchPins(options?: FetchPinnedMessagesOptions): Promise<FetchPinnedMessagesResponse<InGuild>>;
4507
4520
  public react(message: MessageResolvable, emoji: EmojiIdentifierResolvable): Promise<void>;
4508
4521
  public pin(message: MessageResolvable, reason?: string): Promise<void>;
4509
4522
  public unpin(message: MessageResolvable, reason?: string): Promise<void>;
@@ -5787,6 +5800,23 @@ export interface FetchMessagesOptions {
5787
5800
  limit?: number;
5788
5801
  }
5789
5802
 
5803
+ export interface FetchPinnedMessagesOptions {
5804
+ before?: DateResolvable;
5805
+ cache?: boolean;
5806
+ limit?: number;
5807
+ }
5808
+
5809
+ export interface FetchPinnedMessagesResponse<InGuild extends boolean = boolean> {
5810
+ hasMore: boolean;
5811
+ items: readonly MessagePin<InGuild>[];
5812
+ }
5813
+
5814
+ export interface MessagePin<InGuild extends boolean = boolean> {
5815
+ message: Message<InGuild>;
5816
+ get pinnedAt(): Date;
5817
+ pinnedTimestamp: number;
5818
+ }
5819
+
5790
5820
  export interface FetchReactionUsersOptions {
5791
5821
  after?: Snowflake;
5792
5822
  limit?: number;
@@ -170,6 +170,7 @@ import {
170
170
  MessageFlags,
171
171
  MessageReferenceType,
172
172
  MessageType,
173
+ NameplatePalette,
173
174
  OAuth2Scopes,
174
175
  OverwriteType,
175
176
  PermissionFlagsBits,
@@ -3509,6 +3510,17 @@ export interface AvatarDecorationData {
3509
3510
  skuId: Snowflake;
3510
3511
  }
3511
3512
 
3513
+ export interface NameplateData {
3514
+ asset: string;
3515
+ label: string;
3516
+ palette: NameplatePalette;
3517
+ skuId: Snowflake;
3518
+ }
3519
+
3520
+ export interface Collectibles {
3521
+ nameplate: NameplateData | null;
3522
+ }
3523
+
3512
3524
  export interface UnfurledMediaItemData {
3513
3525
  url: string;
3514
3526
  }
@@ -3531,6 +3543,7 @@ export class User extends Base {
3531
3543
  public bot: boolean;
3532
3544
  public get createdAt(): Date;
3533
3545
  public get createdTimestamp(): number;
3546
+ public collectibles: Collectibles | null;
3534
3547
  public discriminator: string;
3535
3548
  public get displayName(): string;
3536
3549
  public get defaultAvatarURL(): string;
@@ -4503,7 +4516,7 @@ export abstract class MessageManager<InGuild extends boolean = boolean> extends
4503
4516
  ): Promise<Message<InGuild>>;
4504
4517
  public fetch(options: FetchMessageOptions | MessageResolvable): Promise<Message<InGuild>>;
4505
4518
  public fetch(options?: FetchMessagesOptions): Promise<Collection<Snowflake, Message<InGuild>>>;
4506
- public fetchPinned(cache?: boolean): Promise<Collection<Snowflake, Message<InGuild>>>;
4519
+ public fetchPins(options?: FetchPinnedMessagesOptions): Promise<FetchPinnedMessagesResponse<InGuild>>;
4507
4520
  public react(message: MessageResolvable, emoji: EmojiIdentifierResolvable): Promise<void>;
4508
4521
  public pin(message: MessageResolvable, reason?: string): Promise<void>;
4509
4522
  public unpin(message: MessageResolvable, reason?: string): Promise<void>;
@@ -5787,6 +5800,23 @@ export interface FetchMessagesOptions {
5787
5800
  limit?: number;
5788
5801
  }
5789
5802
 
5803
+ export interface FetchPinnedMessagesOptions {
5804
+ before?: DateResolvable;
5805
+ cache?: boolean;
5806
+ limit?: number;
5807
+ }
5808
+
5809
+ export interface FetchPinnedMessagesResponse<InGuild extends boolean = boolean> {
5810
+ hasMore: boolean;
5811
+ items: readonly MessagePin<InGuild>[];
5812
+ }
5813
+
5814
+ export interface MessagePin<InGuild extends boolean = boolean> {
5815
+ message: Message<InGuild>;
5816
+ get pinnedAt(): Date;
5817
+ pinnedTimestamp: number;
5818
+ }
5819
+
5790
5820
  export interface FetchReactionUsersOptions {
5791
5821
  after?: Snowflake;
5792
5822
  limit?: number;