discord.js 15.0.0-dev.1765454516-df0c28afc → 15.0.0-dev.1766016119-427636ee7

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.1765454516-df0c28afc",
4
+ "version": "15.0.0-dev.1766016119-427636ee7",
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.16.0",
64
- "@discordjs/builders": "2.0.0-dev.1765454516-df0c28afc",
65
- "@discordjs/formatters": "1.0.0-dev.1765454516-df0c28afc",
66
- "@discordjs/rest": "3.0.0-dev.1765454516-df0c28afc",
67
- "@discordjs/collection": "3.0.0-dev.1765454516-df0c28afc",
68
- "@discordjs/util": "2.0.0-dev.1765454516-df0c28afc",
69
- "@discordjs/ws": "3.0.0-dev.1765454516-df0c28afc"
64
+ "@discordjs/collection": "3.0.0-dev.1766016119-427636ee7",
65
+ "@discordjs/builders": "2.0.0-dev.1766016119-427636ee7",
66
+ "@discordjs/formatters": "1.0.0-dev.1766016119-427636ee7",
67
+ "@discordjs/util": "2.0.0-dev.1766016119-427636ee7",
68
+ "@discordjs/ws": "3.0.0-dev.1766016119-427636ee7",
69
+ "@discordjs/rest": "3.0.0-dev.1766016119-427636ee7"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@favware/cliff-jumper": "^6.0.0",
package/src/index.js CHANGED
@@ -105,6 +105,8 @@ exports.ActionRow = require('./structures/ActionRow.js').ActionRow;
105
105
  exports.Activity = require('./structures/Presence.js').Activity;
106
106
  exports.AnnouncementChannel = require('./structures/AnnouncementChannel.js').AnnouncementChannel;
107
107
  exports.AnonymousGuild = require('./structures/AnonymousGuild.js').AnonymousGuild;
108
+ exports.AuthorizingIntegrationOwners =
109
+ require('./structures/AuthorizingIntegrationOwners.js').AuthorizingIntegrationOwners;
108
110
  exports.Application = require('./structures/interfaces/Application.js').Application;
109
111
  exports.ApplicationCommand = require('./structures/ApplicationCommand.js').ApplicationCommand;
110
112
  exports.ApplicationEmoji = require('./structures/ApplicationEmoji.js').ApplicationEmoji;
@@ -81,6 +81,17 @@ class RoleManager extends CachedManager {
81
81
  return this._add(data, cache);
82
82
  }
83
83
 
84
+ /**
85
+ * Fetches the member count of each role in the guild.
86
+ * <info>This does not include the `@everyone` role.</info>
87
+ *
88
+ * @returns {Promise<Collection<Snowflake, number>>} A collection mapping role ids to their respective member counts.
89
+ */
90
+ async fetchMemberCounts() {
91
+ const data = await this.client.rest.get(Routes.guildRoleMemberCounts(this.guild.id));
92
+ return new Collection(Object.entries(data));
93
+ }
94
+
84
95
  /**
85
96
  * Data that can be resolved to a Role object. This can be:
86
97
  * - A Role
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ const { ApplicationIntegrationType } = require('discord-api-types/v10');
4
+ const { Base } = require('./Base.js');
5
+
6
+ /**
7
+ * Represents the owners of an authorizing integration.
8
+ *
9
+ * @extends {Base}
10
+ */
11
+ class AuthorizingIntegrationOwners extends Base {
12
+ constructor(client, data) {
13
+ super(client);
14
+
15
+ Object.defineProperty(this, 'data', { value: data });
16
+
17
+ // Support accessing authorizingIntegrationOwners[ApplicationIntegrationType.GuildInstall] or similar, + forward compatibility if new installation types get added
18
+ for (const value of Object.values(ApplicationIntegrationType)) {
19
+ if (typeof value !== 'number') {
20
+ continue;
21
+ }
22
+
23
+ Object.defineProperty(this, value, { value: this.data[value] });
24
+ }
25
+
26
+ /**
27
+ * The id of the guild where the integration is installed, if applicable.
28
+ *
29
+ * @type {?Snowflake}
30
+ */
31
+ this.guildId = this.data[ApplicationIntegrationType.GuildInstall] ?? null;
32
+
33
+ /**
34
+ * The id of the user on which the integration is installed, if applicable.
35
+ *
36
+ * @type {?Snowflake}
37
+ */
38
+ this.userId = this.data[ApplicationIntegrationType.UserInstall] ?? null;
39
+ }
40
+
41
+ /**
42
+ * The guild where the integration is installed, if applicable.
43
+ *
44
+ * @type {?Guild}
45
+ */
46
+ get guild() {
47
+ return (this.guildId && this.client.guilds.cache.get(this.guildId)) ?? null;
48
+ }
49
+
50
+ /**
51
+ * The user on which the integration is installed, if applicable.
52
+ *
53
+ * @type {?User}
54
+ */
55
+ get user() {
56
+ return (this.userId && this.client.users.cache.get(this.userId)) ?? null;
57
+ }
58
+
59
+ toJSON() {
60
+ return this.data;
61
+ }
62
+ }
63
+
64
+ exports.AuthorizingIntegrationOwners = AuthorizingIntegrationOwners;
@@ -5,6 +5,7 @@ const { DiscordSnowflake } = require('@sapphire/snowflake');
5
5
  const { InteractionType, ApplicationCommandType, ComponentType } = require('discord-api-types/v10');
6
6
  const { SelectMenuTypes } = require('../util/Constants.js');
7
7
  const { PermissionsBitField } = require('../util/PermissionsBitField.js');
8
+ const { AuthorizingIntegrationOwners } = require('./AuthorizingIntegrationOwners.js');
8
9
  const { Base } = require('./Base.js');
9
10
 
10
11
  /**
@@ -123,12 +124,15 @@ class BaseInteraction extends Base {
123
124
  );
124
125
 
125
126
  /**
126
- * Mapping of installation contexts that the interaction was authorized for the related user or guild ids
127
+ * Mapping of integration types that the application was authorized for the related user or guild ids
127
128
  *
128
- * @type {APIAuthorizingIntegrationOwnersMap}
129
+ * @type {AuthorizingIntegrationOwners}
129
130
  * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-authorizing-integration-owners-object}
130
131
  */
131
- this.authorizingIntegrationOwners = data.authorizing_integration_owners;
132
+ this.authorizingIntegrationOwners = new AuthorizingIntegrationOwners(
133
+ this.client,
134
+ data.authorizing_integration_owners,
135
+ );
132
136
 
133
137
  /**
134
138
  * Context where the interaction was triggered from
@@ -414,8 +414,8 @@ class Message extends Base {
414
414
  * @property {Snowflake} id The interaction's id
415
415
  * @property {InteractionType} type The type of the interaction
416
416
  * @property {User} user The user that invoked the interaction
417
- * @property {APIAuthorizingIntegrationOwnersMap} authorizingIntegrationOwners
418
- * Ids for installation context(s) related to an interaction
417
+ * @property {AuthorizingIntegrationOwners} authorizingIntegrationOwners
418
+ * Mapping of integration types that the application was authorized for the related user or guild ids
419
419
  * @property {?Snowflake} originalResponseMessageId
420
420
  * Id of the original response message. Present only on follow-up messages
421
421
  * @property {?Snowflake} interactedMessageId
@@ -1109,7 +1109,7 @@ class Message extends Base {
1109
1109
  * method allows you to see if there are differences in content, embeds, attachments, nonce and tts properties.
1110
1110
  *
1111
1111
  * @param {Message} message The message to compare it to
1112
- * @param {APIMessage} rawData Raw data passed through the WebSocket about this message
1112
+ * @param {APIMessage} [rawData] Raw data passed through the WebSocket about this message
1113
1113
  * @returns {boolean}
1114
1114
  */
1115
1115
  equals(message, rawData) {
@@ -35,11 +35,6 @@
35
35
  * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationIntegrationType}
36
36
  */
37
37
 
38
- /**
39
- * @external APIAuthorizingIntegrationOwnersMap
40
- * @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIAuthorizingIntegrationOwnersMap}
41
- */
42
-
43
38
  /**
44
39
  * @external APIAutoModerationAction
45
40
  * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIAutoModerationAction}
@@ -2,6 +2,7 @@
2
2
 
3
3
  const { isJSONEncodable } = require('@discordjs/util');
4
4
  const snakeCase = require('lodash.snakecase');
5
+ const { AuthorizingIntegrationOwners } = require('../structures/AuthorizingIntegrationOwners.js');
5
6
 
6
7
  /**
7
8
  * Transforms camel-cased keys into snake cased keys
@@ -48,7 +49,10 @@ function _transformAPIMessageInteractionMetadata(client, messageInteractionMetad
48
49
  id: messageInteractionMetadata.id,
49
50
  type: messageInteractionMetadata.type,
50
51
  user: client.users._add(messageInteractionMetadata.user),
51
- authorizingIntegrationOwners: messageInteractionMetadata.authorizing_integration_owners,
52
+ authorizingIntegrationOwners: new AuthorizingIntegrationOwners(
53
+ client,
54
+ messageInteractionMetadata.authorizing_integration_owners,
55
+ ),
52
56
  originalResponseMessageId: messageInteractionMetadata.original_response_message_id ?? null,
53
57
  interactedMessageId: messageInteractionMetadata.interacted_message_id ?? null,
54
58
  triggeringInteractionMetadata: messageInteractionMetadata.triggering_interaction_metadata
@@ -1927,7 +1927,7 @@ export class BaseInteraction<Cached extends CacheType = CacheType> extends Base
1927
1927
  private readonly _cacheType: Cached;
1928
1928
  protected constructor(client: Client<true>, data: GatewayInteractionCreateDispatchData);
1929
1929
  public applicationId: Snowflake;
1930
- public authorizingIntegrationOwners: APIAuthorizingIntegrationOwnersMap;
1930
+ public authorizingIntegrationOwners: AuthorizingIntegrationOwners;
1931
1931
  public get channel(): CacheTypeReducer<
1932
1932
  Cached,
1933
1933
  GuildTextBasedChannel | null,
@@ -2242,7 +2242,7 @@ export class Message<InGuild extends boolean = boolean> extends Base {
2242
2242
  | MessagePayload
2243
2243
  | string,
2244
2244
  ): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
2245
- public equals(message: Message, rawData: unknown): boolean;
2245
+ public equals(message: Message, rawData?: APIMessage): boolean;
2246
2246
  public fetchReference(): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
2247
2247
  public fetchWebhook(): Promise<Webhook>;
2248
2248
  public crosspost(): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
@@ -2265,6 +2265,22 @@ export class Message<InGuild extends boolean = boolean> extends Base {
2265
2265
  public inGuild(): this is Message<true>;
2266
2266
  }
2267
2267
 
2268
+ export class AuthorizingIntegrationOwners extends Base {
2269
+ private constructor(client: Client<true>, data: APIAuthorizingIntegrationOwnersMap);
2270
+ private readonly data: APIAuthorizingIntegrationOwnersMap;
2271
+
2272
+ // Getters from types
2273
+ public readonly [ApplicationIntegrationType.GuildInstall]?: Snowflake;
2274
+ public readonly [ApplicationIntegrationType.UserInstall]?: Snowflake;
2275
+
2276
+ public readonly guildId: Snowflake | null;
2277
+ public get guild(): Guild | null;
2278
+ public readonly userId: Snowflake | null;
2279
+ public get user(): User | null;
2280
+
2281
+ public toJSON(): APIAuthorizingIntegrationOwnersMap;
2282
+ }
2283
+
2268
2284
  export class Attachment {
2269
2285
  private constructor(data: APIAttachment);
2270
2286
  private readonly attachment: BufferResolvable | Stream;
@@ -4707,6 +4723,7 @@ export class RoleManager extends CachedManager<Snowflake, Role, RoleResolvable>
4707
4723
  public botRoleFor(user: UserResolvable): Role | null;
4708
4724
  public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<Role>;
4709
4725
  public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, Role>>;
4726
+ public fetchMemberCounts(): Promise<Collection<Snowflake, number>>;
4710
4727
  public create(options?: RoleCreateOptions): Promise<Role>;
4711
4728
  public edit(role: RoleResolvable, options: RoleEditOptions): Promise<Role>;
4712
4729
  public delete(role: RoleResolvable, reason?: string): Promise<void>;
@@ -6642,7 +6659,7 @@ export interface MessageChannelComponentCollectorOptions<
6642
6659
  }
6643
6660
 
6644
6661
  export interface MessageInteractionMetadata {
6645
- authorizingIntegrationOwners: APIAuthorizingIntegrationOwnersMap;
6662
+ authorizingIntegrationOwners: AuthorizingIntegrationOwners;
6646
6663
  id: Snowflake;
6647
6664
  interactedMessageId: Snowflake | null;
6648
6665
  originalResponseMessageId: Snowflake | null;
@@ -1927,7 +1927,7 @@ export class BaseInteraction<Cached extends CacheType = CacheType> extends Base
1927
1927
  private readonly _cacheType: Cached;
1928
1928
  protected constructor(client: Client<true>, data: GatewayInteractionCreateDispatchData);
1929
1929
  public applicationId: Snowflake;
1930
- public authorizingIntegrationOwners: APIAuthorizingIntegrationOwnersMap;
1930
+ public authorizingIntegrationOwners: AuthorizingIntegrationOwners;
1931
1931
  public get channel(): CacheTypeReducer<
1932
1932
  Cached,
1933
1933
  GuildTextBasedChannel | null,
@@ -2242,7 +2242,7 @@ export class Message<InGuild extends boolean = boolean> extends Base {
2242
2242
  | MessagePayload
2243
2243
  | string,
2244
2244
  ): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
2245
- public equals(message: Message, rawData: unknown): boolean;
2245
+ public equals(message: Message, rawData?: APIMessage): boolean;
2246
2246
  public fetchReference(): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
2247
2247
  public fetchWebhook(): Promise<Webhook>;
2248
2248
  public crosspost(): Promise<OmitPartialGroupDMChannel<Message<InGuild>>>;
@@ -2265,6 +2265,22 @@ export class Message<InGuild extends boolean = boolean> extends Base {
2265
2265
  public inGuild(): this is Message<true>;
2266
2266
  }
2267
2267
 
2268
+ export class AuthorizingIntegrationOwners extends Base {
2269
+ private constructor(client: Client<true>, data: APIAuthorizingIntegrationOwnersMap);
2270
+ private readonly data: APIAuthorizingIntegrationOwnersMap;
2271
+
2272
+ // Getters from types
2273
+ public readonly [ApplicationIntegrationType.GuildInstall]?: Snowflake;
2274
+ public readonly [ApplicationIntegrationType.UserInstall]?: Snowflake;
2275
+
2276
+ public readonly guildId: Snowflake | null;
2277
+ public get guild(): Guild | null;
2278
+ public readonly userId: Snowflake | null;
2279
+ public get user(): User | null;
2280
+
2281
+ public toJSON(): APIAuthorizingIntegrationOwnersMap;
2282
+ }
2283
+
2268
2284
  export class Attachment {
2269
2285
  private constructor(data: APIAttachment);
2270
2286
  private readonly attachment: BufferResolvable | Stream;
@@ -4707,6 +4723,7 @@ export class RoleManager extends CachedManager<Snowflake, Role, RoleResolvable>
4707
4723
  public botRoleFor(user: UserResolvable): Role | null;
4708
4724
  public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<Role>;
4709
4725
  public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, Role>>;
4726
+ public fetchMemberCounts(): Promise<Collection<Snowflake, number>>;
4710
4727
  public create(options?: RoleCreateOptions): Promise<Role>;
4711
4728
  public edit(role: RoleResolvable, options: RoleEditOptions): Promise<Role>;
4712
4729
  public delete(role: RoleResolvable, reason?: string): Promise<void>;
@@ -6642,7 +6659,7 @@ export interface MessageChannelComponentCollectorOptions<
6642
6659
  }
6643
6660
 
6644
6661
  export interface MessageInteractionMetadata {
6645
- authorizingIntegrationOwners: APIAuthorizingIntegrationOwnersMap;
6662
+ authorizingIntegrationOwners: AuthorizingIntegrationOwners;
6646
6663
  id: Snowflake;
6647
6664
  interactedMessageId: Snowflake | null;
6648
6665
  originalResponseMessageId: Snowflake | null;