discord.js 15.0.0-dev.1736769925-18ab0cf62 → 15.0.0-dev.1736899921-1fd587c93

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.1736769925-18ab0cf62",
4
+ "version": "15.0.0-dev.1736899921-1fd587c93",
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",
@@ -60,10 +60,10 @@
60
60
  "tslib": "^2.8.1",
61
61
  "undici": "6.21.0",
62
62
  "@discordjs/collection": "^2.1.1",
63
- "@discordjs/formatters": "^0.5.0",
64
- "@discordjs/util": "^1.1.1",
65
63
  "@discordjs/rest": "^2.4.0",
66
- "@discordjs/ws": "^2.0.0"
64
+ "@discordjs/ws": "^2.0.0",
65
+ "@discordjs/util": "^1.1.1",
66
+ "@discordjs/formatters": "^0.5.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@favware/cliff-jumper": "^4.1.0",
@@ -81,8 +81,8 @@
81
81
  "turbo": "^2.3.3",
82
82
  "typescript": "~5.5.4",
83
83
  "@discordjs/api-extractor": "^7.38.1",
84
- "@discordjs/docgen": "^0.12.1",
85
- "@discordjs/scripts": "^0.1.0"
84
+ "@discordjs/scripts": "^0.1.0",
85
+ "@discordjs/docgen": "^0.12.1"
86
86
  },
87
87
  "engines": {
88
88
  "node": ">=20"
@@ -70,7 +70,8 @@ const Messages = {
70
70
  [DjsErrorCodes.ChannelNotCached]: 'Could not find the channel where this message came from in the cache!',
71
71
  [DjsErrorCodes.StageChannelResolve]: 'Could not resolve channel to a stage channel.',
72
72
  [DjsErrorCodes.GuildScheduledEventResolve]: 'Could not resolve the guild scheduled event.',
73
- [DjsErrorCodes.FetchOwnerId]: type => `Couldn't resolve the ${type} ownerId to fetch the ${type} member.`,
73
+ [DjsErrorCodes.FetchOwnerId]: type =>
74
+ `Couldn't resolve the ${type} ownerId to fetch the ${type} ${type === 'group DM' ? 'owner' : 'member'}.`,
74
75
 
75
76
  [DjsErrorCodes.InvalidType]: (name, expected, an = false) => `Supplied ${name} is not a${an ? 'n' : ''} ${expected}.`,
76
77
  [DjsErrorCodes.InvalidElement]: (type, name, elem) => `Supplied ${type} ${name} includes an invalid element: ${elem}`,
@@ -1,12 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  const { BaseChannel } = require('./BaseChannel');
4
+ const TextBasedChannel = require('./interfaces/TextBasedChannel');
4
5
  const { DiscordjsError, ErrorCodes } = require('../errors');
5
6
  const PartialGroupDMMessageManager = require('../managers/PartialGroupDMMessageManager');
6
7
 
7
8
  /**
8
9
  * Represents a Partial Group DM Channel on Discord.
9
10
  * @extends {BaseChannel}
11
+ * @implements {TextBasedChannel}
10
12
  */
11
13
  class PartialGroupDMChannel extends BaseChannel {
12
14
  constructor(client, data) {
@@ -44,6 +46,36 @@ class PartialGroupDMChannel extends BaseChannel {
44
46
  * @type {PartialGroupDMMessageManager}
45
47
  */
46
48
  this.messages = new PartialGroupDMMessageManager(this);
49
+
50
+ if ('owner_id' in data) {
51
+ /**
52
+ * The user id of the owner of this Group DM Channel
53
+ * @type {?Snowflake}
54
+ */
55
+ this.ownerId = data.owner_id;
56
+ } else {
57
+ this.ownerId ??= null;
58
+ }
59
+
60
+ if ('last_message_id' in data) {
61
+ /**
62
+ * The channel's last message id, if one was sent
63
+ * @type {?Snowflake}
64
+ */
65
+ this.lastMessageId = data.last_message_id;
66
+ } else {
67
+ this.lastMessageId ??= null;
68
+ }
69
+
70
+ if ('last_pin_timestamp' in data) {
71
+ /**
72
+ * The timestamp when the last pinned message was pinned, if there was one
73
+ * @type {?number}
74
+ */
75
+ this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
76
+ } else {
77
+ this.lastPinTimestamp ??= null;
78
+ }
47
79
  }
48
80
 
49
81
  /**
@@ -55,6 +87,19 @@ class PartialGroupDMChannel extends BaseChannel {
55
87
  return this.icon && this.client.rest.cdn.channelIcon(this.id, this.icon, options);
56
88
  }
57
89
 
90
+ /**
91
+ * Fetches the owner of this Group DM Channel.
92
+ * @param {BaseFetchOptions} [options] The options for fetching the user
93
+ * @returns {Promise<User>}
94
+ */
95
+ async fetchOwner(options) {
96
+ if (!this.ownerId) {
97
+ throw new DiscordjsError(ErrorCodes.FetchOwnerId, 'group DM');
98
+ }
99
+
100
+ return this.client.users.fetch(this.ownerId, options);
101
+ }
102
+
58
103
  delete() {
59
104
  return Promise.reject(new DiscordjsError(ErrorCodes.DeleteGroupDMChannel));
60
105
  }
@@ -62,6 +107,25 @@ class PartialGroupDMChannel extends BaseChannel {
62
107
  fetch() {
63
108
  return Promise.reject(new DiscordjsError(ErrorCodes.FetchGroupDMChannel));
64
109
  }
110
+
111
+ // These are here only for documentation purposes - they are implemented by TextBasedChannel
112
+ /* eslint-disable no-empty-function */
113
+ get lastMessage() {}
114
+ get lastPinAt() {}
115
+ createMessageComponentCollector() {}
116
+ awaitMessageComponent() {}
65
117
  }
66
118
 
119
+ TextBasedChannel.applyToClass(PartialGroupDMChannel, true, [
120
+ 'bulkDelete',
121
+ 'send',
122
+ 'sendTyping',
123
+ 'createMessageCollector',
124
+ 'awaitMessages',
125
+ 'fetchWebhooks',
126
+ 'createWebhook',
127
+ 'setRateLimitPerUser',
128
+ 'setNSFW',
129
+ ]);
130
+
67
131
  module.exports = PartialGroupDMChannel;
@@ -141,8 +141,7 @@ class Webhook {
141
141
 
142
142
  /**
143
143
  * Options that can be passed into editMessage.
144
- * @typedef {BaseMessageOptions} WebhookMessageEditOptions
145
- * @property {Attachment[]} [attachments] Attachments to send with the message
144
+ * @typedef {MessageEditOptions} WebhookMessageEditOptions
146
145
  * @property {Snowflake} [threadId] The id of the thread this message belongs to
147
146
  * <info>For interaction webhooks, this property is ignored</info>
148
147
  */
@@ -1312,7 +1312,7 @@ export class ContextMenuCommandInteraction<Cached extends CacheType = CacheType>
1312
1312
  // tslint:disable-next-line no-empty-interface
1313
1313
  export interface DMChannel
1314
1314
  extends Omit<
1315
- TextBasedChannelFields<false>,
1315
+ TextBasedChannelFields<false, true>,
1316
1316
  'bulkDelete' | 'fetchWebhooks' | 'createWebhook' | 'setRateLimitPerUser' | 'setNSFW'
1317
1317
  > {}
1318
1318
  export class DMChannel extends BaseChannel {
@@ -2595,6 +2595,19 @@ export class OAuth2Guild extends BaseGuild {
2595
2595
  public permissions: Readonly<PermissionsBitField>;
2596
2596
  }
2597
2597
 
2598
+ export interface PartialGroupDMChannel
2599
+ extends Omit<
2600
+ TextBasedChannelFields<false, false>,
2601
+ | 'bulkDelete'
2602
+ | 'send'
2603
+ | 'sendTyping'
2604
+ | 'createMessageCollector'
2605
+ | 'awaitMessages'
2606
+ | 'fetchWebhooks'
2607
+ | 'createWebhook'
2608
+ | 'setRateLimitPerUser'
2609
+ | 'setNSFW'
2610
+ > {}
2598
2611
  export class PartialGroupDMChannel extends BaseChannel {
2599
2612
  private constructor(client: Client<true>, data: RawPartialGroupDMChannelData);
2600
2613
  public type: ChannelType.GroupDM;
@@ -2602,8 +2615,9 @@ export class PartialGroupDMChannel extends BaseChannel {
2602
2615
  public name: string | null;
2603
2616
  public icon: string | null;
2604
2617
  public recipients: PartialRecipient[];
2605
- public messages: PartialGroupDMMessageManager;
2618
+ public ownerId: Snowflake | null;
2606
2619
  public iconURL(options?: ImageURLOptions): string | null;
2620
+ public fetchOwner(options?: BaseFetchOptions): Promise<User>;
2607
2621
  public toString(): ChannelMention;
2608
2622
  }
2609
2623
 
@@ -4556,13 +4570,13 @@ export interface PartialTextBasedChannelFields<InGuild extends boolean = boolean
4556
4570
  send(options: string | MessagePayload | MessageCreateOptions): Promise<Message<InGuild>>;
4557
4571
  }
4558
4572
 
4559
- export interface TextBasedChannelFields<InGuild extends boolean = boolean>
4573
+ export interface TextBasedChannelFields<InGuild extends boolean = boolean, InDM extends boolean = boolean>
4560
4574
  extends PartialTextBasedChannelFields<InGuild> {
4561
4575
  lastMessageId: Snowflake | null;
4562
4576
  get lastMessage(): Message | null;
4563
4577
  lastPinTimestamp: number | null;
4564
4578
  get lastPinAt(): Date | null;
4565
- messages: If<InGuild, GuildMessageManager, DMMessageManager>;
4579
+ messages: If<InGuild, GuildMessageManager, If<InDM, DMMessageManager, PartialGroupDMMessageManager>>;
4566
4580
  awaitMessageComponent<ComponentType extends MessageComponentType>(
4567
4581
  options?: AwaitMessageCollectorOptionsParams<ComponentType, true>,
4568
4582
  ): Promise<MappedInteractionTypes[ComponentType]>;
@@ -6170,10 +6184,7 @@ export interface InteractionCollectorOptions<
6170
6184
  }
6171
6185
 
6172
6186
  export interface InteractionDeferReplyOptions {
6173
- flags?: BitFieldResolvable<
6174
- Extract<MessageFlagsString, 'Ephemeral' | 'SuppressEmbeds' | 'SuppressNotifications'>,
6175
- MessageFlags.Ephemeral | MessageFlags.SuppressEmbeds | MessageFlags.SuppressNotifications
6176
- >;
6187
+ flags?: BitFieldResolvable<Extract<MessageFlagsString, 'Ephemeral'>, MessageFlags.Ephemeral>;
6177
6188
  withResponse?: boolean;
6178
6189
  }
6179
6190
 
@@ -6896,7 +6907,7 @@ export interface WebhookEditOptions {
6896
6907
  reason?: string;
6897
6908
  }
6898
6909
 
6899
- export interface WebhookMessageEditOptions extends Omit<MessageEditOptions, 'flags'> {
6910
+ export interface WebhookMessageEditOptions extends MessageEditOptions {
6900
6911
  threadId?: Snowflake;
6901
6912
  }
6902
6913
 
@@ -1312,7 +1312,7 @@ export class ContextMenuCommandInteraction<Cached extends CacheType = CacheType>
1312
1312
  // tslint:disable-next-line no-empty-interface
1313
1313
  export interface DMChannel
1314
1314
  extends Omit<
1315
- TextBasedChannelFields<false>,
1315
+ TextBasedChannelFields<false, true>,
1316
1316
  'bulkDelete' | 'fetchWebhooks' | 'createWebhook' | 'setRateLimitPerUser' | 'setNSFW'
1317
1317
  > {}
1318
1318
  export class DMChannel extends BaseChannel {
@@ -2595,6 +2595,19 @@ export class OAuth2Guild extends BaseGuild {
2595
2595
  public permissions: Readonly<PermissionsBitField>;
2596
2596
  }
2597
2597
 
2598
+ export interface PartialGroupDMChannel
2599
+ extends Omit<
2600
+ TextBasedChannelFields<false, false>,
2601
+ | 'bulkDelete'
2602
+ | 'send'
2603
+ | 'sendTyping'
2604
+ | 'createMessageCollector'
2605
+ | 'awaitMessages'
2606
+ | 'fetchWebhooks'
2607
+ | 'createWebhook'
2608
+ | 'setRateLimitPerUser'
2609
+ | 'setNSFW'
2610
+ > {}
2598
2611
  export class PartialGroupDMChannel extends BaseChannel {
2599
2612
  private constructor(client: Client<true>, data: RawPartialGroupDMChannelData);
2600
2613
  public type: ChannelType.GroupDM;
@@ -2602,8 +2615,9 @@ export class PartialGroupDMChannel extends BaseChannel {
2602
2615
  public name: string | null;
2603
2616
  public icon: string | null;
2604
2617
  public recipients: PartialRecipient[];
2605
- public messages: PartialGroupDMMessageManager;
2618
+ public ownerId: Snowflake | null;
2606
2619
  public iconURL(options?: ImageURLOptions): string | null;
2620
+ public fetchOwner(options?: BaseFetchOptions): Promise<User>;
2607
2621
  public toString(): ChannelMention;
2608
2622
  }
2609
2623
 
@@ -4556,13 +4570,13 @@ export interface PartialTextBasedChannelFields<InGuild extends boolean = boolean
4556
4570
  send(options: string | MessagePayload | MessageCreateOptions): Promise<Message<InGuild>>;
4557
4571
  }
4558
4572
 
4559
- export interface TextBasedChannelFields<InGuild extends boolean = boolean>
4573
+ export interface TextBasedChannelFields<InGuild extends boolean = boolean, InDM extends boolean = boolean>
4560
4574
  extends PartialTextBasedChannelFields<InGuild> {
4561
4575
  lastMessageId: Snowflake | null;
4562
4576
  get lastMessage(): Message | null;
4563
4577
  lastPinTimestamp: number | null;
4564
4578
  get lastPinAt(): Date | null;
4565
- messages: If<InGuild, GuildMessageManager, DMMessageManager>;
4579
+ messages: If<InGuild, GuildMessageManager, If<InDM, DMMessageManager, PartialGroupDMMessageManager>>;
4566
4580
  awaitMessageComponent<ComponentType extends MessageComponentType>(
4567
4581
  options?: AwaitMessageCollectorOptionsParams<ComponentType, true>,
4568
4582
  ): Promise<MappedInteractionTypes[ComponentType]>;
@@ -6170,10 +6184,7 @@ export interface InteractionCollectorOptions<
6170
6184
  }
6171
6185
 
6172
6186
  export interface InteractionDeferReplyOptions {
6173
- flags?: BitFieldResolvable<
6174
- Extract<MessageFlagsString, 'Ephemeral' | 'SuppressEmbeds' | 'SuppressNotifications'>,
6175
- MessageFlags.Ephemeral | MessageFlags.SuppressEmbeds | MessageFlags.SuppressNotifications
6176
- >;
6187
+ flags?: BitFieldResolvable<Extract<MessageFlagsString, 'Ephemeral'>, MessageFlags.Ephemeral>;
6177
6188
  withResponse?: boolean;
6178
6189
  }
6179
6190
 
@@ -6896,7 +6907,7 @@ export interface WebhookEditOptions {
6896
6907
  reason?: string;
6897
6908
  }
6898
6909
 
6899
- export interface WebhookMessageEditOptions extends Omit<MessageEditOptions, 'flags'> {
6910
+ export interface WebhookMessageEditOptions extends MessageEditOptions {
6900
6911
  threadId?: Snowflake;
6901
6912
  }
6902
6913