discord.js 15.0.0-dev.1752538515-5a611be8d → 15.0.0-dev.1752667557-9ff04820b

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.1752538515-5a611be8d",
4
+ "version": "15.0.0-dev.1752667557-9ff04820b",
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/builders": "^1.11.1",
65
64
  "@discordjs/collection": "^2.1.1",
66
- "@discordjs/formatters": "^0.6.1",
67
65
  "@discordjs/rest": "^2.5.0",
66
+ "@discordjs/formatters": "^0.6.1",
67
+ "@discordjs/ws": "^2.0.2",
68
68
  "@discordjs/util": "^1.1.1",
69
- "@discordjs/ws": "^2.0.2"
69
+ "@discordjs/builders": "^1.11.1"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@favware/cliff-jumper": "^4.1.0",
@@ -82,8 +82,8 @@
82
82
  "tsd": "^0.32.0",
83
83
  "turbo": "^2.5.4",
84
84
  "typescript": "~5.8.3",
85
- "@discordjs/api-extractor": "^7.52.7",
86
85
  "@discordjs/docgen": "^0.12.1",
86
+ "@discordjs/api-extractor": "^7.52.7",
87
87
  "@discordjs/scripts": "^0.1.0"
88
88
  },
89
89
  "engines": {
@@ -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
  /**
@@ -139,18 +139,22 @@ class User extends Base {
139
139
  * @property {Snowflake} skuId The id of the avatar decoration's SKU
140
140
  */
141
141
 
142
- if (data.avatar_decoration_data) {
143
- /**
144
- * The user avatar decoration's data
145
- *
146
- * @type {?AvatarDecorationData}
147
- */
148
- this.avatarDecorationData = {
149
- asset: data.avatar_decoration_data.asset,
150
- skuId: data.avatar_decoration_data.sku_id,
151
- };
142
+ if ('avatar_decoration_data' in data) {
143
+ if (data.avatar_decoration_data) {
144
+ /**
145
+ * The user avatar decoration's data
146
+ *
147
+ * @type {?AvatarDecorationData}
148
+ */
149
+ this.avatarDecorationData = {
150
+ asset: data.avatar_decoration_data.asset,
151
+ skuId: data.avatar_decoration_data.sku_id,
152
+ };
153
+ } else {
154
+ this.avatarDecorationData = null;
155
+ }
152
156
  } else {
153
- this.avatarDecorationData = null;
157
+ this.avatarDecorationData ??= null;
154
158
  }
155
159
 
156
160
  /**
@@ -176,6 +180,34 @@ class User extends Base {
176
180
  } else {
177
181
  this.collectibles = null;
178
182
  }
183
+
184
+ /**
185
+ * @typedef {Object} UserPrimaryGuild
186
+ * @property {?Snowflake} identityGuildId The id of the user's primary guild
187
+ * @property {?boolean} identityEnabled Whether the user is displaying the primary guild's tag
188
+ * @property {?string} tag The user's guild tag. Limited to 4 characters
189
+ * @property {?string} badge The guild tag badge hash
190
+ */
191
+
192
+ if ('primary_guild' in data) {
193
+ if (data.primary_guild) {
194
+ /**
195
+ * The primary guild of the user
196
+ *
197
+ * @type {?UserPrimaryGuild}
198
+ */
199
+ this.primaryGuild = {
200
+ identityGuildId: data.primary_guild.identity_guild_id,
201
+ identityEnabled: data.primary_guild.identity_enabled,
202
+ tag: data.primary_guild.tag,
203
+ badge: data.primary_guild.badge,
204
+ };
205
+ } else {
206
+ this.primaryGuild = null;
207
+ }
208
+ } else {
209
+ this.primaryGuild ??= null;
210
+ }
179
211
  }
180
212
 
181
213
  /**
@@ -271,6 +303,18 @@ class User extends Base {
271
303
  return this.banner && this.client.rest.cdn.banner(this.id, this.banner, options);
272
304
  }
273
305
 
306
+ /**
307
+ * A link to the user's guild tag badge.
308
+ *
309
+ * @param {ImageURLOptions} [options={}] Options for the image URL
310
+ * @returns {?string}
311
+ */
312
+ guildTagBadgeURL(options = {}) {
313
+ return this.primaryGuild?.badge
314
+ ? this.client.rest.cdn.guildTagBadge(this.primaryGuild.identityGuildId, this.primaryGuild.badge, options)
315
+ : null;
316
+ }
317
+
274
318
  /**
275
319
  * The tag of this user
276
320
  * <info>This user's username, or their legacy tag (e.g. `hydrabolt#0001`)
@@ -367,7 +411,11 @@ class User extends Base {
367
411
  this.collectibles?.nameplate?.skuId === user.collectibles?.nameplate?.skuId &&
368
412
  this.collectibles?.nameplate?.asset === user.collectibles?.nameplate?.asset &&
369
413
  this.collectibles?.nameplate?.label === user.collectibles?.nameplate?.label &&
370
- this.collectibles?.nameplate?.palette === user.collectibles?.nameplate?.palette
414
+ this.collectibles?.nameplate?.palette === user.collectibles?.nameplate?.palette &&
415
+ this.primaryGuild?.identityGuildId === user.primaryGuild?.identityGuildId &&
416
+ this.primaryGuild?.identityEnabled === user.primaryGuild?.identityEnabled &&
417
+ this.primaryGuild?.tag === user.primaryGuild?.tag &&
418
+ this.primaryGuild?.badge === user.primaryGuild?.badge
371
419
  );
372
420
  }
373
421
 
@@ -398,6 +446,12 @@ class User extends Base {
398
446
  this.collectibles?.nameplate?.asset === user.collectibles?.nameplate?.asset &&
399
447
  this.collectibles?.nameplate?.label === user.collectibles?.nameplate?.label &&
400
448
  this.collectibles?.nameplate?.palette === user.collectibles?.nameplate?.palette
449
+ : true) &&
450
+ ('primary_guild' in user
451
+ ? this.primaryGuild?.identityGuildId === user.primary_guild?.identity_guild_id &&
452
+ this.primaryGuild?.identityEnabled === user.primary_guild?.identity_enabled &&
453
+ this.primaryGuild?.tag === user.primary_guild?.tag &&
454
+ this.primaryGuild?.badge === user.primary_guild?.badge
401
455
  : true)
402
456
  );
403
457
  }
@@ -437,6 +491,7 @@ class User extends Base {
437
491
  json.avatarURL = this.avatarURL();
438
492
  json.displayAvatarURL = this.displayAvatarURL();
439
493
  json.bannerURL = this.banner ? this.bannerURL() : this.banner;
494
+ json.guildTagBadgeURL = this.guildTagBadgeURL();
440
495
  return json;
441
496
  }
442
497
  }
@@ -31,10 +31,7 @@ import {
31
31
  APIComponentInModalActionRow,
32
32
  APIContainerComponent,
33
33
  APIEmbed,
34
- APIEmbedAuthor,
35
34
  APIEmbedField,
36
- APIEmbedFooter,
37
- APIEmbedImage,
38
35
  APIEmbedProvider,
39
36
  APIEmoji,
40
37
  APIEntitlement,
@@ -3510,6 +3507,17 @@ export interface AvatarDecorationData {
3510
3507
  skuId: Snowflake;
3511
3508
  }
3512
3509
 
3510
+ export interface Collectibles {
3511
+ nameplate: NameplateData | null;
3512
+ }
3513
+
3514
+ export interface UserPrimaryGuild {
3515
+ badge: string | null;
3516
+ identityEnabled: boolean | null;
3517
+ identityGuildId: Snowflake | null;
3518
+ tag: string | null;
3519
+ }
3520
+
3513
3521
  export interface NameplateData {
3514
3522
  asset: string;
3515
3523
  label: string;
@@ -3517,10 +3525,6 @@ export interface NameplateData {
3517
3525
  skuId: Snowflake;
3518
3526
  }
3519
3527
 
3520
- export interface Collectibles {
3521
- nameplate: NameplateData | null;
3522
- }
3523
-
3524
3528
  export interface UnfurledMediaItemData {
3525
3529
  url: string;
3526
3530
  }
@@ -3553,12 +3557,14 @@ export class User extends Base {
3553
3557
  public get hexAccentColor(): HexColorString | null | undefined;
3554
3558
  public id: Snowflake;
3555
3559
  public get partial(): false;
3560
+ public primaryGuild: UserPrimaryGuild | null;
3556
3561
  public system: boolean;
3557
3562
  public get tag(): string;
3558
3563
  public username: string;
3559
3564
  public avatarURL(options?: ImageURLOptions): string | null;
3560
3565
  public avatarDecorationURL(): string | null;
3561
3566
  public bannerURL(options?: ImageURLOptions): string | null | undefined;
3567
+ public guildTagBadgeURL(options?: ImageURLOptions): string | null;
3562
3568
  public createDM(force?: boolean): Promise<DMChannel>;
3563
3569
  public deleteDM(): Promise<DMChannel>;
3564
3570
  public displayAvatarURL(options?: ImageURLOptions): string;
@@ -4516,7 +4522,7 @@ export abstract class MessageManager<InGuild extends boolean = boolean> extends
4516
4522
  ): Promise<Message<InGuild>>;
4517
4523
  public fetch(options: FetchMessageOptions | MessageResolvable): Promise<Message<InGuild>>;
4518
4524
  public fetch(options?: FetchMessagesOptions): Promise<Collection<Snowflake, Message<InGuild>>>;
4519
- public fetchPinned(cache?: boolean): Promise<Collection<Snowflake, Message<InGuild>>>;
4525
+ public fetchPins(options?: FetchPinnedMessagesOptions): Promise<FetchPinnedMessagesResponse<InGuild>>;
4520
4526
  public react(message: MessageResolvable, emoji: EmojiIdentifierResolvable): Promise<void>;
4521
4527
  public pin(message: MessageResolvable, reason?: string): Promise<void>;
4522
4528
  public unpin(message: MessageResolvable, reason?: string): Promise<void>;
@@ -5800,6 +5806,23 @@ export interface FetchMessagesOptions {
5800
5806
  limit?: number;
5801
5807
  }
5802
5808
 
5809
+ export interface FetchPinnedMessagesOptions {
5810
+ before?: DateResolvable;
5811
+ cache?: boolean;
5812
+ limit?: number;
5813
+ }
5814
+
5815
+ export interface FetchPinnedMessagesResponse<InGuild extends boolean = boolean> {
5816
+ hasMore: boolean;
5817
+ items: readonly MessagePin<InGuild>[];
5818
+ }
5819
+
5820
+ export interface MessagePin<InGuild extends boolean = boolean> {
5821
+ message: Message<InGuild>;
5822
+ get pinnedAt(): Date;
5823
+ pinnedTimestamp: number;
5824
+ }
5825
+
5803
5826
  export interface FetchReactionUsersOptions {
5804
5827
  after?: Snowflake;
5805
5828
  limit?: number;
@@ -31,10 +31,7 @@ import {
31
31
  APIComponentInModalActionRow,
32
32
  APIContainerComponent,
33
33
  APIEmbed,
34
- APIEmbedAuthor,
35
34
  APIEmbedField,
36
- APIEmbedFooter,
37
- APIEmbedImage,
38
35
  APIEmbedProvider,
39
36
  APIEmoji,
40
37
  APIEntitlement,
@@ -3510,6 +3507,17 @@ export interface AvatarDecorationData {
3510
3507
  skuId: Snowflake;
3511
3508
  }
3512
3509
 
3510
+ export interface Collectibles {
3511
+ nameplate: NameplateData | null;
3512
+ }
3513
+
3514
+ export interface UserPrimaryGuild {
3515
+ badge: string | null;
3516
+ identityEnabled: boolean | null;
3517
+ identityGuildId: Snowflake | null;
3518
+ tag: string | null;
3519
+ }
3520
+
3513
3521
  export interface NameplateData {
3514
3522
  asset: string;
3515
3523
  label: string;
@@ -3517,10 +3525,6 @@ export interface NameplateData {
3517
3525
  skuId: Snowflake;
3518
3526
  }
3519
3527
 
3520
- export interface Collectibles {
3521
- nameplate: NameplateData | null;
3522
- }
3523
-
3524
3528
  export interface UnfurledMediaItemData {
3525
3529
  url: string;
3526
3530
  }
@@ -3553,12 +3557,14 @@ export class User extends Base {
3553
3557
  public get hexAccentColor(): HexColorString | null | undefined;
3554
3558
  public id: Snowflake;
3555
3559
  public get partial(): false;
3560
+ public primaryGuild: UserPrimaryGuild | null;
3556
3561
  public system: boolean;
3557
3562
  public get tag(): string;
3558
3563
  public username: string;
3559
3564
  public avatarURL(options?: ImageURLOptions): string | null;
3560
3565
  public avatarDecorationURL(): string | null;
3561
3566
  public bannerURL(options?: ImageURLOptions): string | null | undefined;
3567
+ public guildTagBadgeURL(options?: ImageURLOptions): string | null;
3562
3568
  public createDM(force?: boolean): Promise<DMChannel>;
3563
3569
  public deleteDM(): Promise<DMChannel>;
3564
3570
  public displayAvatarURL(options?: ImageURLOptions): string;
@@ -4516,7 +4522,7 @@ export abstract class MessageManager<InGuild extends boolean = boolean> extends
4516
4522
  ): Promise<Message<InGuild>>;
4517
4523
  public fetch(options: FetchMessageOptions | MessageResolvable): Promise<Message<InGuild>>;
4518
4524
  public fetch(options?: FetchMessagesOptions): Promise<Collection<Snowflake, Message<InGuild>>>;
4519
- public fetchPinned(cache?: boolean): Promise<Collection<Snowflake, Message<InGuild>>>;
4525
+ public fetchPins(options?: FetchPinnedMessagesOptions): Promise<FetchPinnedMessagesResponse<InGuild>>;
4520
4526
  public react(message: MessageResolvable, emoji: EmojiIdentifierResolvable): Promise<void>;
4521
4527
  public pin(message: MessageResolvable, reason?: string): Promise<void>;
4522
4528
  public unpin(message: MessageResolvable, reason?: string): Promise<void>;
@@ -5800,6 +5806,23 @@ export interface FetchMessagesOptions {
5800
5806
  limit?: number;
5801
5807
  }
5802
5808
 
5809
+ export interface FetchPinnedMessagesOptions {
5810
+ before?: DateResolvable;
5811
+ cache?: boolean;
5812
+ limit?: number;
5813
+ }
5814
+
5815
+ export interface FetchPinnedMessagesResponse<InGuild extends boolean = boolean> {
5816
+ hasMore: boolean;
5817
+ items: readonly MessagePin<InGuild>[];
5818
+ }
5819
+
5820
+ export interface MessagePin<InGuild extends boolean = boolean> {
5821
+ message: Message<InGuild>;
5822
+ get pinnedAt(): Date;
5823
+ pinnedTimestamp: number;
5824
+ }
5825
+
5803
5826
  export interface FetchReactionUsersOptions {
5804
5827
  after?: Snowflake;
5805
5828
  limit?: number;