Skip to content

Commit

Permalink
feat: add new API fields to BaseInteraction
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet committed May 19, 2024
1 parent 7832e89 commit dae9cc5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ export abstract class BaseInteraction<T extends BaseInteractionType = BaseIntera
return this.application_id;
}

/**
* Mapping of installation contexts that the interaction was authorized for
* to related user or guild IDs.
*/
public get authorizing_integration_owners(): T['authorizing_integration_owners'] {
return this[Data].authorizing_integration_owners;
}

/**
* Mapping of installation contexts that the interaction was authorized for
* to related user or guild IDs.
*
* @seealso {@link authorizing_integration_owners} for the raw data.
*/
public get authorizingIntegrationOwners(): T['authorizing_integration_owners'] {
return this.authorizing_integration_owners;
}

/**
* The channel of the interaction.
*/
Expand All @@ -102,13 +120,28 @@ export abstract class BaseInteraction<T extends BaseInteractionType = BaseIntera
return this.channel?.id;
}

/**
* Context where the interaction was triggered from.
*/
public get context(): T['context'] {
return this[Data].context;
}

/**
* The command data payload.
*/
public get data(): T['data'] {
return this[Data].data;
}

/**
* For monetized apps, any entitlements for the invoking user, representing
* access to premium SKUs.
*/
public get entitlements(): T['entitlements'] {
return this[Data].entitlements;
}

/**
* The guild the interaction was sent from.
*/
Expand Down
6 changes: 4 additions & 2 deletions packages/http-framework/tests/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
type APIUserApplicationCommandInteraction,
type LocaleString,
type Permissions,
type APIEntitlement
type APIEntitlement,
type APIAuthorizingIntegrationOwnersMap
} from 'discord-api-types/v10';
import type { ServerResponse } from 'node:http';
import { Writable } from 'node:stream';
Expand Down Expand Up @@ -78,7 +79,8 @@ export const BaseInteractionData = {
locale: LocaleData,
guild_locale: LocaleData,
guild_id: '737141877803057244',
entitlements: [] as APIEntitlement[]
entitlements: [] as APIEntitlement[],
authorizing_integration_owners: {} as APIAuthorizingIntegrationOwnersMap
} as const;

export const ApplicationCommandAutocompleteInteractionData: APIApplicationCommandAutocompleteInteraction = {
Expand Down

0 comments on commit dae9cc5

Please # to comment.