From 6c77fee41b1aabc243bff623debd157a4c7fad6a Mon Sep 17 00:00:00 2001 From: Ryan Munro Date: Tue, 24 Sep 2024 00:13:14 +1000 Subject: [PATCH] fix(BaseInteraction): add missing props (#10517) * fix(AutocompleteInteraction): add missing authorizingIntegrationOwners * fix(AutocompleteInteraction): add missing context * fix(AutocompleteInteraction): types * fix: move to BaseInteraction * fix: remove props from CommandInteraction * Update packages/discord.js/typings/index.d.ts Co-authored-by: Danial Raza --------- Co-authored-by: Vlad Frangu Co-authored-by: Danial Raza --- .../discord.js/src/structures/BaseInteraction.js | 15 +++++++++++++++ .../src/structures/CommandInteraction.js | 15 --------------- packages/discord.js/typings/index.d.ts | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/discord.js/src/structures/BaseInteraction.js b/packages/discord.js/src/structures/BaseInteraction.js index db778080b..28d1e4b35 100644 --- a/packages/discord.js/src/structures/BaseInteraction.js +++ b/packages/discord.js/src/structures/BaseInteraction.js @@ -107,6 +107,21 @@ class BaseInteraction extends Base { (coll, entitlement) => coll.set(entitlement.id, this.client.application.entitlements._add(entitlement)), new Collection(), ); + + /* eslint-disable max-len */ + /** + * Mapping of installation contexts that the interaction was authorized for the related user or guild ids + * @type {APIAuthorizingIntegrationOwnersMap} + * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-authorizing-integration-owners-object} + */ + this.authorizingIntegrationOwners = data.authorizing_integration_owners; + /* eslint-enable max-len */ + + /** + * Context where the interaction was triggered from + * @type {?InteractionContextType} + */ + this.context = data.context ?? null; } /** diff --git a/packages/discord.js/src/structures/CommandInteraction.js b/packages/discord.js/src/structures/CommandInteraction.js index 2dec12300..0d435deeb 100644 --- a/packages/discord.js/src/structures/CommandInteraction.js +++ b/packages/discord.js/src/structures/CommandInteraction.js @@ -45,21 +45,6 @@ class CommandInteraction extends BaseInteraction { */ this.commandGuildId = data.data.guild_id ?? null; - /* eslint-disable max-len */ - /** - * Mapping of installation contexts that the interaction was authorized for the related user or guild ids - * @type {APIAuthorizingIntegrationOwnersMap} - * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-authorizing-integration-owners-object} - */ - this.authorizingIntegrationOwners = data.authorizing_integration_owners; - /* eslint-enable max-len */ - - /** - * Context where the interaction was triggered from - * @type {?InteractionContextType} - */ - this.context = data.context ?? null; - /** * Whether the reply to this interaction has been deferred * @type {boolean} diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 771623c5c..25eaab583 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -547,7 +547,6 @@ export type GuildCacheMessage = CacheTypeReducer< export type BooleanCache = Cached extends 'cached' ? true : false; export abstract class CommandInteraction extends BaseInteraction { - public authorizingIntegrationOwners: APIAuthorizingIntegrationOwnersMap; public type: InteractionType.ApplicationCommand; public get command(): ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null; public options: Omit< @@ -572,7 +571,6 @@ export abstract class CommandInteraction e public commandName: string; public commandType: ApplicationCommandType; public commandGuildId: Snowflake | null; - public context: InteractionContextType | null; public deferred: boolean; public ephemeral: boolean | null; public replied: boolean; @@ -1925,6 +1923,7 @@ export class BaseInteraction extends Base private readonly _cacheType: Cached; protected constructor(client: Client, data: RawInteractionData); public applicationId: Snowflake; + public authorizingIntegrationOwners: APIAuthorizingIntegrationOwnersMap; public get channel(): CacheTypeReducer< Cached, GuildTextBasedChannel | null, @@ -1933,6 +1932,7 @@ export class BaseInteraction extends Base TextBasedChannel | null >; public channelId: Snowflake | null; + public context: InteractionContextType | null; public get createdAt(): Date; public get createdTimestamp(): number; public get guild(): CacheTypeReducer;