discord.js 15.0.0-dev.1732752781-e89c6b66a → 15.0.0-dev.1732839163-5b125eeec

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.
Files changed (35) hide show
  1. package/package.json +6 -6
  2. package/src/client/actions/ThreadListSync.js +1 -1
  3. package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.js +14 -0
  4. package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.js +16 -0
  5. package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.js +16 -0
  6. package/src/client/websocket/handlers/index.js +3 -0
  7. package/src/index.js +5 -0
  8. package/src/managers/BaseGuildEmojiManager.js +2 -2
  9. package/src/managers/GuildBanManager.js +1 -1
  10. package/src/managers/GuildChannelManager.js +5 -5
  11. package/src/managers/GuildMemberManager.js +2 -2
  12. package/src/managers/PresenceManager.js +4 -4
  13. package/src/managers/SubscriptionManager.js +81 -0
  14. package/src/managers/ThreadMemberManager.js +3 -3
  15. package/src/structures/ClientApplication.js +7 -0
  16. package/src/structures/Entitlement.js +2 -6
  17. package/src/structures/GuildMember.js +1 -1
  18. package/src/structures/GuildOnboardingPromptOption.js +1 -1
  19. package/src/structures/InteractionCallback.js +74 -0
  20. package/src/structures/InteractionCallbackResource.js +52 -0
  21. package/src/structures/InteractionCallbackResponse.js +33 -0
  22. package/src/structures/Invite.js +1 -1
  23. package/src/structures/Message.js +1 -1
  24. package/src/structures/PermissionOverwrites.js +1 -1
  25. package/src/structures/PollAnswer.js +1 -1
  26. package/src/structures/Subscription.js +109 -0
  27. package/src/structures/ThreadMember.js +2 -2
  28. package/src/structures/Webhook.js +2 -2
  29. package/src/structures/WelcomeChannel.js +1 -1
  30. package/src/structures/interfaces/InteractionResponses.js +48 -22
  31. package/src/util/APITypes.js +4 -4
  32. package/src/util/Events.js +6 -0
  33. package/typings/index.d.mts +117 -21
  34. package/typings/index.d.ts +117 -21
  35. package/typings/index.test-d.ts +38 -43
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.1732752781-e89c6b66a",
4
+ "version": "15.0.0-dev.1732839163-5b125eeec",
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
  "lodash.snakecase": "4.1.1",
61
61
  "tslib": "^2.8.1",
62
62
  "undici": "6.21.0",
63
- "@discordjs/formatters": "^0.5.0",
64
- "@discordjs/ws": "^2.0.0",
63
+ "@discordjs/rest": "^2.4.0",
65
64
  "@discordjs/util": "^1.1.1",
66
- "@discordjs/rest": "^2.4.0"
65
+ "@discordjs/ws": "^2.0.0",
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.0",
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"
@@ -13,7 +13,7 @@ class ThreadListSyncAction extends Action {
13
13
 
14
14
  if (data.channel_ids) {
15
15
  for (const id of data.channel_ids) {
16
- const channel = client.channels.resolve(id);
16
+ const channel = client.channels.cache.get(id);
17
17
  if (channel) this.removeStale(channel);
18
18
  }
19
19
  } else {
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ const Events = require('../../../util/Events');
4
+
5
+ module.exports = (client, { d: data }) => {
6
+ const subscription = client.application.subscriptions._add(data);
7
+
8
+ /**
9
+ * Emitted whenever a subscription is created.
10
+ * @event Client#subscriptionCreate
11
+ * @param {Subscription} subscription The subscription that was created
12
+ */
13
+ client.emit(Events.SubscriptionCreate, subscription);
14
+ };
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ const Events = require('../../../util/Events');
4
+
5
+ module.exports = (client, { d: data }) => {
6
+ const subscription = client.application.subscriptions._add(data, false);
7
+
8
+ client.application.subscriptions.cache.delete(subscription.id);
9
+
10
+ /**
11
+ * Emitted whenever a subscription is deleted.
12
+ * @event Client#subscriptionDelete
13
+ * @param {Subscription} subscription The subscription that was deleted
14
+ */
15
+ client.emit(Events.SubscriptionDelete, subscription);
16
+ };
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ const Events = require('../../../util/Events');
4
+
5
+ module.exports = (client, { d: data }) => {
6
+ const oldSubscription = client.application.subscriptions.cache.get(data.id)?._clone() ?? null;
7
+ const newSubscription = client.application.subscriptions._add(data);
8
+
9
+ /**
10
+ * Emitted whenever a subscription is updated - i.e. when a user's subscription renews.
11
+ * @event Client#subscriptionUpdate
12
+ * @param {?Subscription} oldSubscription The subscription before the update
13
+ * @param {Subscription} newSubscription The subscription after the update
14
+ */
15
+ client.emit(Events.SubscriptionUpdate, oldSubscription, newSubscription);
16
+ };
@@ -52,6 +52,9 @@ const handlers = Object.fromEntries([
52
52
  ['STAGE_INSTANCE_CREATE', require('./STAGE_INSTANCE_CREATE')],
53
53
  ['STAGE_INSTANCE_DELETE', require('./STAGE_INSTANCE_DELETE')],
54
54
  ['STAGE_INSTANCE_UPDATE', require('./STAGE_INSTANCE_UPDATE')],
55
+ ['SUBSCRIPTION_CREATE', require('./SUBSCRIPTION_CREATE')],
56
+ ['SUBSCRIPTION_DELETE', require('./SUBSCRIPTION_DELETE')],
57
+ ['SUBSCRIPTION_UPDATE', require('./SUBSCRIPTION_UPDATE')],
55
58
  ['THREAD_CREATE', require('./THREAD_CREATE')],
56
59
  ['THREAD_DELETE', require('./THREAD_DELETE')],
57
60
  ['THREAD_LIST_SYNC', require('./THREAD_LIST_SYNC')],
package/src/index.js CHANGED
@@ -83,6 +83,7 @@ exports.ReactionManager = require('./managers/ReactionManager');
83
83
  exports.ReactionUserManager = require('./managers/ReactionUserManager');
84
84
  exports.RoleManager = require('./managers/RoleManager');
85
85
  exports.StageInstanceManager = require('./managers/StageInstanceManager');
86
+ exports.SubscriptionManager = require('./managers/SubscriptionManager').SubscriptionManager;
86
87
  exports.ThreadManager = require('./managers/ThreadManager');
87
88
  exports.ThreadMemberManager = require('./managers/ThreadMemberManager');
88
89
  exports.UserManager = require('./managers/UserManager');
@@ -142,6 +143,9 @@ exports.GuildScheduledEvent = require('./structures/GuildScheduledEvent').GuildS
142
143
  exports.GuildTemplate = require('./structures/GuildTemplate');
143
144
  exports.Integration = require('./structures/Integration');
144
145
  exports.IntegrationApplication = require('./structures/IntegrationApplication');
146
+ exports.InteractionCallback = require('./structures/InteractionCallback');
147
+ exports.InteractionCallbackResource = require('./structures/InteractionCallbackResource');
148
+ exports.InteractionCallbackResponse = require('./structures/InteractionCallbackResponse');
145
149
  exports.BaseInteraction = require('./structures/BaseInteraction');
146
150
  exports.InteractionCollector = require('./structures/InteractionCollector');
147
151
  exports.InteractionResponse = require('./structures/InteractionResponse');
@@ -193,6 +197,7 @@ exports.SKU = require('./structures/SKU').SKU;
193
197
  exports.StringSelectMenuOptionBuilder = require('./structures/StringSelectMenuOptionBuilder');
194
198
  exports.StageChannel = require('./structures/StageChannel');
195
199
  exports.StageInstance = require('./structures/StageInstance').StageInstance;
200
+ exports.Subscription = require('./structures/Subscription').Subscription;
196
201
  exports.Sticker = require('./structures/Sticker').Sticker;
197
202
  exports.StickerPack = require('./structures/StickerPack');
198
203
  exports.Team = require('./structures/Team');
@@ -36,8 +36,8 @@ class BaseGuildEmojiManager extends CachedManager {
36
36
  * @returns {?GuildEmoji}
37
37
  */
38
38
  resolve(emoji) {
39
- if (emoji instanceof ReactionEmoji) return super.resolve(emoji.id);
40
- if (emoji instanceof ApplicationEmoji) return super.resolve(emoji.id);
39
+ if (emoji instanceof ReactionEmoji) return super.cache.get(emoji.id) ?? null;
40
+ if (emoji instanceof ApplicationEmoji) return super.cache.get(emoji.id) ?? null;
41
41
  return super.resolve(emoji);
42
42
  }
43
43
 
@@ -158,7 +158,7 @@ class GuildBanManager extends CachedManager {
158
158
  reason: options.reason,
159
159
  });
160
160
  if (user instanceof GuildMember) return user;
161
- const _user = this.client.users.resolve(id);
161
+ const _user = this.client.users.cache.get(id);
162
162
  if (_user) {
163
163
  return this.guild.members.resolve(_user) ?? _user;
164
164
  }
@@ -84,7 +84,7 @@ class GuildChannelManager extends CachedManager {
84
84
  * @returns {?(GuildChannel|ThreadChannel)}
85
85
  */
86
86
  resolve(channel) {
87
- if (channel instanceof ThreadChannel) return super.resolve(channel.id);
87
+ if (channel instanceof ThreadChannel) return super.cache.get(channel.id) ?? null;
88
88
  return super.resolve(channel);
89
89
  }
90
90
 
@@ -287,7 +287,7 @@ class GuildChannelManager extends CachedManager {
287
287
  const resolvedChannel = this.resolve(channel);
288
288
  if (!resolvedChannel) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'channel', 'GuildChannelResolvable');
289
289
 
290
- const parent = options.parent && this.client.channels.resolveId(options.parent);
290
+ const parentId = options.parent && this.client.channels.resolveId(options.parent);
291
291
 
292
292
  if (options.position !== undefined) {
293
293
  await this.setPosition(resolvedChannel, options.position, { position: options.position, reason: options.reason });
@@ -298,8 +298,8 @@ class GuildChannelManager extends CachedManager {
298
298
  );
299
299
 
300
300
  if (options.lockPermissions) {
301
- if (parent) {
302
- const newParent = this.resolve(parent);
301
+ if (parentId) {
302
+ const newParent = this.cache.get(parentId);
303
303
  if (newParent?.type === ChannelType.GuildCategory) {
304
304
  permission_overwrites = newParent.permissionOverwrites.cache.map(overwrite =>
305
305
  PermissionOverwrites.resolve(overwrite, this.guild),
@@ -322,7 +322,7 @@ class GuildChannelManager extends CachedManager {
322
322
  user_limit: options.userLimit,
323
323
  rtc_region: options.rtcRegion,
324
324
  video_quality_mode: options.videoQualityMode,
325
- parent_id: parent,
325
+ parent_id: parentId,
326
326
  lock_permissions: options.lockPermissions,
327
327
  rate_limit_per_user: options.rateLimitPerUser,
328
328
  default_auto_archive_duration: options.defaultAutoArchiveDuration,
@@ -55,7 +55,7 @@ class GuildMemberManager extends CachedManager {
55
55
  const memberResolvable = super.resolve(member);
56
56
  if (memberResolvable) return memberResolvable;
57
57
  const userResolvable = this.client.users.resolveId(member);
58
- if (userResolvable) return super.resolve(userResolvable);
58
+ if (userResolvable) return super.cache.get(userResolvable) ?? null;
59
59
  return null;
60
60
  }
61
61
 
@@ -144,7 +144,7 @@ class GuildMemberManager extends CachedManager {
144
144
  */
145
145
  get me() {
146
146
  return (
147
- this.resolve(this.client.user.id) ??
147
+ this.cache.get(this.client.user.id) ??
148
148
  (this.client.options.partials.includes(Partials.GuildMember)
149
149
  ? this._add({ user: { id: this.client.user.id } }, true)
150
150
  : null)
@@ -38,8 +38,8 @@ class PresenceManager extends CachedManager {
38
38
  resolve(presence) {
39
39
  const presenceResolvable = super.resolve(presence);
40
40
  if (presenceResolvable) return presenceResolvable;
41
- const UserResolvable = this.client.users.resolveId(presence);
42
- return super.resolve(UserResolvable);
41
+ const userId = this.client.users.resolveId(presence);
42
+ return super.cache.get(userId) ?? null;
43
43
  }
44
44
 
45
45
  /**
@@ -50,8 +50,8 @@ class PresenceManager extends CachedManager {
50
50
  resolveId(presence) {
51
51
  const presenceResolvable = super.resolveId(presence);
52
52
  if (presenceResolvable) return presenceResolvable;
53
- const userResolvable = this.client.users.resolveId(presence);
54
- return this.cache.has(userResolvable) ? userResolvable : null;
53
+ const userId = this.client.users.resolveId(presence);
54
+ return this.cache.has(userId) ? userId : null;
55
55
  }
56
56
  }
57
57
 
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ const { Collection } = require('@discordjs/collection');
4
+ const { makeURLSearchParams } = require('@discordjs/rest');
5
+ const { Routes } = require('discord-api-types/v10');
6
+ const CachedManager = require('./CachedManager');
7
+ const { DiscordjsTypeError, ErrorCodes } = require('../errors/index');
8
+ const { Subscription } = require('../structures/Subscription');
9
+ const { resolveSKUId } = require('../util/Util');
10
+
11
+ /**
12
+ * Manages API methods for subscriptions and stores their cache.
13
+ * @extends {CachedManager}
14
+ */
15
+ class SubscriptionManager extends CachedManager {
16
+ constructor(client, iterable) {
17
+ super(client, Subscription, iterable);
18
+ }
19
+
20
+ /**
21
+ * The cache of this manager
22
+ * @type {Collection<Snowflake, Subscription>}
23
+ * @name SubscriptionManager#cache
24
+ */
25
+
26
+ /**
27
+ * Options used to fetch a subscription
28
+ * @typedef {BaseFetchOptions} FetchSubscriptionOptions
29
+ * @property {SKUResolvable} sku The SKU to fetch the subscription for
30
+ * @property {Snowflake} subscriptionId The id of the subscription to fetch
31
+ */
32
+
33
+ /**
34
+ * Options used to fetch subscriptions
35
+ * @typedef {Object} FetchSubscriptionsOptions
36
+ * @property {Snowflake} [after] Consider only subscriptions after this subscription id
37
+ * @property {Snowflake} [before] Consider only subscriptions before this subscription id
38
+ * @property {number} [limit] The maximum number of subscriptions to fetch
39
+ * @property {SKUResolvable} sku The SKU to fetch subscriptions for
40
+ * @property {UserResolvable} user The user to fetch entitlements for
41
+ * <warn>If both `before` and `after` are provided, only `before` is respected</warn>
42
+ */
43
+
44
+ /**
45
+ * Fetches subscriptions for this application
46
+ * @param {FetchSubscriptionOptions|FetchSubscriptionsOptions} [options={}] Options for fetching the subscriptions
47
+ * @returns {Promise<Subscription|Collection<Snowflake, Subscription>>}
48
+ */
49
+ async fetch(options = {}) {
50
+ if (typeof options !== 'object') throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
51
+
52
+ const { after, before, cache, limit, sku, subscriptionId, user } = options;
53
+
54
+ const skuId = resolveSKUId(sku);
55
+
56
+ if (!skuId) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'sku', 'SKUResolvable');
57
+
58
+ if (subscriptionId) {
59
+ const subscription = await this.client.rest.get(Routes.skuSubscription(skuId, subscriptionId));
60
+
61
+ return this._add(subscription, cache);
62
+ }
63
+
64
+ const query = makeURLSearchParams({
65
+ limit,
66
+ user_id: this.client.users.resolveId(user) ?? undefined,
67
+ sku_id: skuId,
68
+ before,
69
+ after,
70
+ });
71
+
72
+ const subscriptions = await this.client.rest.get(Routes.skuSubscriptions(skuId), { query });
73
+
74
+ return subscriptions.reduce(
75
+ (coll, subscription) => coll.set(subscription.id, this._add(subscription, cache)),
76
+ new Collection(),
77
+ );
78
+ }
79
+ }
80
+
81
+ exports.SubscriptionManager = SubscriptionManager;
@@ -53,7 +53,7 @@ class ThreadMemberManager extends CachedManager {
53
53
  * @readonly
54
54
  */
55
55
  get me() {
56
- return this.resolve(this.client.user.id);
56
+ return this.cache.get(this.client.user.id) ?? null;
57
57
  }
58
58
 
59
59
  /**
@@ -71,8 +71,8 @@ class ThreadMemberManager extends CachedManager {
71
71
  resolve(member) {
72
72
  const memberResolvable = super.resolve(member);
73
73
  if (memberResolvable) return memberResolvable;
74
- const userResolvable = this.client.users.resolveId(member);
75
- if (userResolvable) return super.resolve(userResolvable);
74
+ const userId = this.client.users.resolveId(member);
75
+ if (userId) return super.cache.get(userId) ?? null;
76
76
  return null;
77
77
  }
78
78
 
@@ -9,6 +9,7 @@ const Application = require('./interfaces/Application');
9
9
  const ApplicationCommandManager = require('../managers/ApplicationCommandManager');
10
10
  const ApplicationEmojiManager = require('../managers/ApplicationEmojiManager');
11
11
  const { EntitlementManager } = require('../managers/EntitlementManager');
12
+ const { SubscriptionManager } = require('../managers/SubscriptionManager');
12
13
  const ApplicationFlagsBitField = require('../util/ApplicationFlagsBitField');
13
14
  const { resolveImage } = require('../util/DataResolver');
14
15
  const PermissionsBitField = require('../util/PermissionsBitField');
@@ -44,6 +45,12 @@ class ClientApplication extends Application {
44
45
  * @type {EntitlementManager}
45
46
  */
46
47
  this.entitlements = new EntitlementManager(this.client);
48
+
49
+ /**
50
+ * The subscription manager for this application
51
+ * @type {SubscriptionManager}
52
+ */
53
+ this.subscriptions = new SubscriptionManager(this.client);
47
54
  }
48
55
 
49
56
  _patch(data) {
@@ -73,10 +73,9 @@ class Entitlement extends Base {
73
73
  if ('starts_at' in data) {
74
74
  /**
75
75
  * The timestamp at which this entitlement is valid
76
- * <info>This is only `null` for test entitlements</info>
77
76
  * @type {?number}
78
77
  */
79
- this.startsTimestamp = Date.parse(data.starts_at);
78
+ this.startsTimestamp = data.starts_at ? Date.parse(data.starts_at) : null;
80
79
  } else {
81
80
  this.startsTimestamp ??= null;
82
81
  }
@@ -84,10 +83,9 @@ class Entitlement extends Base {
84
83
  if ('ends_at' in data) {
85
84
  /**
86
85
  * The timestamp at which this entitlement is no longer valid
87
- * <info>This is only `null` for test entitlements</info>
88
86
  * @type {?number}
89
87
  */
90
- this.endsTimestamp = Date.parse(data.ends_at);
88
+ this.endsTimestamp = data.ends_at ? Date.parse(data.ends_at) : null;
91
89
  } else {
92
90
  this.endsTimestamp ??= null;
93
91
  }
@@ -114,7 +112,6 @@ class Entitlement extends Base {
114
112
 
115
113
  /**
116
114
  * The start date at which this entitlement is valid
117
- * <info>This is only `null` for test entitlements</info>
118
115
  * @type {?Date}
119
116
  */
120
117
  get startsAt() {
@@ -123,7 +120,6 @@ class Entitlement extends Base {
123
120
 
124
121
  /**
125
122
  * The end date at which this entitlement is no longer valid
126
- * <info>This is only `null` for test entitlements</info>
127
123
  * @type {?Date}
128
124
  */
129
125
  get endsAt() {
@@ -228,7 +228,7 @@ class GuildMember extends Base {
228
228
  * @readonly
229
229
  */
230
230
  get presence() {
231
- return this.guild.presences.resolve(this.id);
231
+ return this.guild.presences.cache.get(this.id) ?? null;
232
232
  }
233
233
 
234
234
  /**
@@ -79,7 +79,7 @@ class GuildOnboardingPromptOption extends Base {
79
79
  */
80
80
  get emoji() {
81
81
  if (!this._emoji.id && !this._emoji.name) return null;
82
- return this.client.emojis.resolve(this._emoji.id) ?? new Emoji(this.client, this._emoji);
82
+ return this.client.emojis.cache.get(this._emoji.id) ?? new Emoji(this.client, this._emoji);
83
83
  }
84
84
  }
85
85
 
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ const { DiscordSnowflake } = require('@sapphire/snowflake');
4
+
5
+ /**
6
+ * Represents an interaction callback response from Discord
7
+ */
8
+ class InteractionCallback {
9
+ constructor(client, data) {
10
+ /**
11
+ * The client that instantiated this.
12
+ * @name InteractionCallback#client
13
+ * @type {Client}
14
+ * @readonly
15
+ */
16
+ Object.defineProperty(this, 'client', { value: client });
17
+
18
+ /**
19
+ * The id of the original interaction response
20
+ * @type {Snowflake}
21
+ */
22
+ this.id = data.id;
23
+
24
+ /**
25
+ * The type of the original interaction
26
+ * @type {InteractionType}
27
+ */
28
+ this.type = data.type;
29
+
30
+ /**
31
+ * The instance id of the Activity if one was launched or joined
32
+ * @type {?string}
33
+ */
34
+ this.activityInstanceId = data.activity_instance_id ?? null;
35
+
36
+ /**
37
+ * The id of the message that was created by the interaction
38
+ * @type {?Snowflake}
39
+ */
40
+ this.responseMessageId = data.response_message_id ?? null;
41
+
42
+ /**
43
+ * Whether the message is in a loading state
44
+ * @type {?boolean}
45
+ */
46
+ this.responseMessageLoading = data.response_message_loading ?? null;
47
+
48
+ /**
49
+ * Whether the response message was ephemeral
50
+ * @type {?boolean}
51
+ */
52
+ this.responseMessageEphemeral = data.response_message_ephemeral ?? null;
53
+ }
54
+
55
+ /**
56
+ * The timestamp the original interaction was created at
57
+ * @type {number}
58
+ * @readonly
59
+ */
60
+ get createdTimestamp() {
61
+ return DiscordSnowflake.timestampFrom(this.id);
62
+ }
63
+
64
+ /**
65
+ * The time the original interaction was created at
66
+ * @type {Date}
67
+ * @readonly
68
+ */
69
+ get createdAt() {
70
+ return new Date(this.createdTimestamp);
71
+ }
72
+ }
73
+
74
+ module.exports = InteractionCallback;
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ const { lazy } = require('@discordjs/util');
4
+
5
+ const getMessage = lazy(() => require('./Message').Message);
6
+
7
+ /**
8
+ * Represents the resource that was created by the interaction response.
9
+ */
10
+ class InteractionCallbackResource {
11
+ constructor(client, data) {
12
+ /**
13
+ * The client that instantiated this
14
+ * @name InteractionCallbackResource#client
15
+ * @type {Client}
16
+ * @readonly
17
+ */
18
+ Object.defineProperty(this, 'client', { value: client });
19
+
20
+ /**
21
+ * The interaction callback type
22
+ * @type {InteractionResponseType}
23
+ */
24
+ this.type = data.type;
25
+
26
+ /**
27
+ * The Activity launched by an interaction
28
+ * @typedef {Object} ActivityInstance
29
+ * @property {string} id The instance id of the Activity
30
+ */
31
+
32
+ /**
33
+ * Represents the Activity launched by this interaction
34
+ * @type {?ActivityInstance}
35
+ */
36
+ this.activityInstance = data.activity_instance ?? null;
37
+
38
+ if ('message' in data) {
39
+ /**
40
+ * The message created by the interaction
41
+ * @type {?Message}
42
+ */
43
+ this.message =
44
+ this.client.channels.cache.get(data.message.channel_id)?.messages._add(data.message) ??
45
+ new (getMessage())(client, data.message);
46
+ } else {
47
+ this.message = null;
48
+ }
49
+ }
50
+ }
51
+
52
+ module.exports = InteractionCallbackResource;
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ const InteractionCallback = require('./InteractionCallback');
4
+ const InteractionCallbackResource = require('./InteractionCallbackResource');
5
+
6
+ /**
7
+ * Represents an interaction's response
8
+ */
9
+ class InteractionCallbackResponse {
10
+ constructor(client, data) {
11
+ /**
12
+ * The client that instantiated this
13
+ * @name InteractionCallbackResponse#client
14
+ * @type {Client}
15
+ * @readonly
16
+ */
17
+ Object.defineProperty(this, 'client', { value: client });
18
+
19
+ /**
20
+ * The interaction object associated with the interaction callback response
21
+ * @type {InteractionCallback}
22
+ */
23
+ this.interaction = new InteractionCallback(client, data.interaction);
24
+
25
+ /**
26
+ * The resource that was created by the interaction response
27
+ * @type {?InteractionCallbackResource}
28
+ */
29
+ this.resource = data.resource ? new InteractionCallbackResource(client, data.resource) : null;
30
+ }
31
+ }
32
+
33
+ module.exports = InteractionCallbackResponse;
@@ -39,7 +39,7 @@ class Invite extends Base {
39
39
  */
40
40
  this.guild ??= null;
41
41
  if (data.guild) {
42
- this.guild = this.client.guilds.resolve(data.guild.id) ?? new InviteGuild(this.client, data.guild);
42
+ this.guild = this.client.guilds.cache.get(data.guild.id) ?? new InviteGuild(this.client, data.guild);
43
43
  }
44
44
 
45
45
  if ('code' in data) {
@@ -570,7 +570,7 @@ class Message extends Base {
570
570
  * @readonly
571
571
  */
572
572
  get thread() {
573
- return this.channel?.threads?.resolve(this.id) ?? null;
573
+ return this.channel?.threads?.cache.get(this.id) ?? null;
574
574
  }
575
575
 
576
576
  /**
@@ -180,7 +180,7 @@ class PermissionOverwrites extends Base {
180
180
  };
181
181
  }
182
182
 
183
- const userOrRole = guild.roles.resolve(overwrite.id) ?? guild.client.users.resolve(overwrite.id);
183
+ const userOrRole = guild.roles.cache.get(overwrite.id) ?? guild.client.users.cache.get(overwrite.id);
184
184
  if (!userOrRole) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'parameter', 'User nor a Role');
185
185
  const type = userOrRole instanceof Role ? OverwriteType.Role : OverwriteType.Member;
186
186
 
@@ -61,7 +61,7 @@ class PollAnswer extends Base {
61
61
  */
62
62
  get emoji() {
63
63
  if (!this._emoji || (!this._emoji.id && !this._emoji.name)) return null;
64
- return this.client.emojis.resolve(this._emoji.id) ?? new Emoji(this.client, this._emoji);
64
+ return this.client.emojis.cache.get(this._emoji.id) ?? new Emoji(this.client, this._emoji);
65
65
  }
66
66
 
67
67
  /**