From a36e623d44c06986768d5d6a73618d4fef64924d Mon Sep 17 00:00:00 2001 From: Donovan Daniels Date: Mon, 18 Mar 2024 19:00:33 -0500 Subject: [PATCH] User installed apps discord/discord-api-docs#6723 discord/discord-api-docs#6726 discord/discord-api-docs#6727 discord/discord-api-docs#6728 --- lib/Constants.ts | 11 +++++ lib/routes/Applications.ts | 9 +++- lib/structures/Application.ts | 18 ++++++- lib/structures/ApplicationCommand.ts | 10 +++- lib/structures/AutocompleteInteraction.ts | 43 ++++++++++------ lib/structures/CommandInteraction.ts | 37 ++++++++------ lib/structures/ComponentInteraction.ts | 41 +++++++++++----- lib/structures/Message.ts | 48 ++++++++++++++++-- lib/structures/ModalSubmitInteraction.ts | 35 ++++++++----- lib/structures/OAuthApplication.ts | 60 ++++++++++++++--------- lib/structures/Webhook.ts | 3 +- lib/types/applications.d.ts | 43 ++++++++++++---- lib/types/channels.d.ts | 25 +++++++++- lib/types/interactions.d.ts | 14 ++++-- lib/types/json.d.ts | 48 +++++++++++++++--- 15 files changed, 336 insertions(+), 109 deletions(-) diff --git a/lib/Constants.ts b/lib/Constants.ts index 57e7a87a..211e9126 100644 --- a/lib/Constants.ts +++ b/lib/Constants.ts @@ -112,6 +112,17 @@ export enum UserFlags { RESTRICTED_COLLABORATOR = 2 ** 51, } +export enum ApplicationIntegrationTypes { + GUILD_INSTALL = 0, + USER_INSTALL = 1, +} + +export enum InteractionContextTypes { + GUILD = 0, + BOT_DM = 1, + PRIVATE_CHANNEL = 2, +} + export enum ApplicationFlags { EMBEDDED_RELEASED = 1 << 1, MANAGED_EMOJI = 1 << 2, diff --git a/lib/routes/Applications.ts b/lib/routes/Applications.ts index f8b13168..59f09597 100644 --- a/lib/routes/Applications.ts +++ b/lib/routes/Applications.ts @@ -49,10 +49,12 @@ export default class Applications { method: "PUT", path: Routes.APPLICATION_COMMANDS(applicationID), json: opts.map(opt => ({ - default_member_permissions: opt.defaultMemberPermissions, + contexts: opt.contexts, description: opt.description, + default_member_permissions: opt.defaultMemberPermissions, description_localizations: opt.descriptionLocalizations, dm_permission: opt.dmPermission, + integration_types: opt.integrationTypes, name: opt.name, name_localizations: opt.nameLocalizations, nsfw: opt.nsfw, @@ -101,10 +103,12 @@ export default class Applications { method: "POST", path: Routes.APPLICATION_COMMANDS(applicationID), json: { + contexts: opt.contexts, default_member_permissions: opt.defaultMemberPermissions, description: opt.description, description_localizations: opt.descriptionLocalizations, dm_permission: opt.dmPermission, + integration_types: opt.integrationTypes, name: opt.name, name_localizations: opt.nameLocalizations, nsfw: opt.nsfw, @@ -220,6 +224,7 @@ export default class Applications { flags: options.flags, icon: options.icon, install_params: options.installParams, + integration_types_config: options.integrationTypesConfig, interactions_endpoint_url: options.interactionsEndpointURL, role_connections_verification_url: options.roleConnectionsVerificationURL, tags: options.tags @@ -240,10 +245,12 @@ export default class Applications { method: "PATCH", path: Routes.APPLICATION_COMMAND(applicationID, commandID), json: { + contexts: opt.contexts, default_member_permissions: opt.defaultMemberPermissions, description: opt.description, description_localizations: opt.descriptionLocalizations, dm_permission: opt.dmPermission, + integration_types: opt.integrationTypes, name: opt.name, name_localizations: opt.nameLocalizations, nsfw: opt.nsfw, diff --git a/lib/structures/Application.ts b/lib/structures/Application.ts index 7186ec29..c4fcca9e 100644 --- a/lib/structures/Application.ts +++ b/lib/structures/Application.ts @@ -3,10 +3,10 @@ import ClientApplication from "./ClientApplication"; import OAuthGuild from "./OAuthGuild"; import type Client from "../Client"; import type { InstallParams } from "../types/oauth"; -import type { ImageFormat } from "../Constants"; +import type { ApplicationIntegrationTypes, ImageFormat } from "../Constants"; import * as Routes from "../util/Routes"; import type { JSONApplication } from "../types/json"; -import type { RESTApplication } from "../types"; +import type { IntegrationTypesConfig, RESTApplication } from "../types"; /** Represents an application. */ export default class Application extends ClientApplication { @@ -26,6 +26,10 @@ export default class Application extends ClientApplication { icon: string | null; /** Settings for this application's in-app authorization link, if enabled. */ installParams?: InstallParams; + /** The install types available for this application. */ + integrationTypes: Array; + /** The configs for the install types available for this application. */ + integrationTypesConfig: IntegrationTypesConfig; /** This applications interaction endpoint url, if any. */ interactionsEndpointURL: string | null; /** The name of the application. */ @@ -56,6 +60,8 @@ export default class Application extends ClientApplication { this.guild = null; this.guildID = data.guild_id ?? null; this.icon = null; + this.integrationTypes = []; + this.integrationTypesConfig = {}; this.interactionsEndpointURL = null; this.name = data.name; this.roleConnectionsVerificationURL = null; @@ -89,6 +95,12 @@ export default class Application extends ClientApplication { if (data.install_params !== undefined) { this.installParams = data.install_params; } + if (data.integration_types !== undefined) { + this.integrationTypes = data.integration_types; + } + if (data.integration_types_config !== undefined) { + this.integrationTypesConfig = Object.fromEntries(Object.entries(data.integration_types_config).map(([key, value]) => [key, { oauth2InstallParams: value.oauth2_install_params }])); + } if (data.interactions_endpoint_url !== undefined) { this.interactionsEndpointURL = data.interactions_endpoint_url; } @@ -153,6 +165,8 @@ export default class Application extends ClientApplication { guildID: this.guildID, icon: this.icon, installParams: this.installParams, + integrationTypes: this.integrationTypes, + integrationTypesConfig: this.integrationTypesConfig, interactionsEndpointURL: this.interactionsEndpointURL, name: this.name, primarySKUID: this.primarySKUID, diff --git a/lib/structures/ApplicationCommand.ts b/lib/structures/ApplicationCommand.ts index b362ab7f..9549bcf0 100644 --- a/lib/structures/ApplicationCommand.ts +++ b/lib/structures/ApplicationCommand.ts @@ -4,7 +4,7 @@ import Permission from "./Permission"; import type Guild from "./Guild"; import type ClientApplication from "./ClientApplication"; import type Client from "../Client"; -import { ApplicationCommandTypes } from "../Constants"; +import { ApplicationCommandTypes, type InteractionContextTypes, type ApplicationIntegrationTypes } from "../Constants"; import type { ApplicationCommandOptionConversion, ApplicationCommandOptions, @@ -24,6 +24,8 @@ export default class ApplicationCommand; /** The default permissions for this command. */ defaultMemberPermissions: Permission | null; /** The description of this command. Empty string for non `CHAT_INPUT` commands. */ @@ -36,6 +38,8 @@ export default class ApplicationCommand; /** The name of this command. */ name: string; /** A dictionary of [locales](https://discord.com/developers/docs/reference#locales) to localized names. */ @@ -54,12 +58,14 @@ export default class ApplicationCommand extends Interaction { private _cachedChannel!: T extends AnyInteractionChannel ? T : undefined; private _cachedGuild?: T extends AnyTextableGuildChannel ? Guild : Guild | null; - /** The permissions the bot has in the channel this interaction was sent from, if this interaction is sent from a guild. */ - appPermissions: T extends AnyTextableGuildChannel ? Permission : Permission | undefined; + /** The permissions the bot has in the channel this interaction was sent from. If in a dm/group dm, this will contain `ATTACH_FILES`, `EMBED_LINKS`, and `MENTION_EVERYONE`. In addition, `USE_EXTERNAL_EMOJIS` will be included for DMs with the app's bot user. */ + appPermissions: Permission; + /** Details about the authorizing user or server for the installation(s) relevant to the interaction. See [Discord's docs](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-authorizing-integration-owners-object) for more information. */ + authorizingIntegrationOwners: AuthorizingIntegrationOwners; /** The ID of the channel this interaction was sent from. */ channelID: string; + /** The context this interaction was sent from. */ + context?: InteractionContextTypes; /** The data associated with the interaction. */ data: AutocompleteInteractionData; /** The entitlements for the user that created this interaction, and the guild it was created in. */ @@ -46,8 +56,10 @@ export default class AutocompleteInteraction extends Interaction { private _cachedChannel!: T extends AnyInteractionChannel ? T : undefined; private _cachedGuild?: T extends AnyTextableGuildChannel ? Guild : Guild | null; - /** The permissions the bot has in the channel this interaction was sent from, if this interaction is sent from a guild. */ - appPermissions: T extends AnyTextableGuildChannel ? Permission : Permission | undefined; + /** The permissions the bot has in the channel this interaction was sent from. If in a dm/group dm, this will contain `ATTACH_FILES`, `EMBED_LINKS`, and `MENTION_EVERYONE`. In addition, `USE_EXTERNAL_EMOJIS` will be included for DMs with the app's bot user. */ + appPermissions: Permission; + /** Details about the authorizing user or server for the installation(s) relevant to the interaction. See [Discord's docs](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-authorizing-integration-owners-object) for more information. */ + authorizingIntegrationOwners: AuthorizingIntegrationOwners; /** The ID of the channel this interaction was sent from. */ channelID: string; + /** The context this interaction was sent from. */ + context?: InteractionContextTypes; /** The data associated with the interaction. */ data: ApplicationCommandInteractionData; /** The entitlements for the user that created this interaction, and the guild it was created in. */ @@ -62,8 +67,10 @@ export default class CommandInteraction extends Interaction { private _cachedChannel!: T extends AnyInteractionChannel ? T : undefined; private _cachedGuild?: T extends AnyTextableGuildChannel ? Guild : Guild | null; - /** The permissions the bot has in the channel this interaction was sent from, if this interaction is sent from a guild. */ - appPermissions: T extends AnyTextableGuildChannel ? Permission : Permission | undefined; + /** The permissions the bot has in the channel this interaction was sent from. If in a dm/group dm, this will contain `ATTACH_FILES`, `EMBED_LINKS`, and `MENTION_EVERYONE`. In addition, `USE_EXTERNAL_EMOJIS` will be included for DMs with the app's bot user. */ + appPermissions: Permission; + /** Details about the authorizing user or server for the installation(s) relevant to the interaction. See [Discord's docs](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-authorizing-integration-owners-object) for more information. */ + authorizingIntegrationOwners: AuthorizingIntegrationOwners; /** The ID of the channel this interaction was sent from. */ channelID: string; + /** The context this interaction was sent from. */ + context?: InteractionContextTypes; /** The data associated with the interaction. */ data: V extends ComponentTypes.BUTTON ? MessageComponentButtonInteractionData : MessageComponentSelectMenuInteractionData; /** The entitlements for the user that created this interaction, and the guild it was created in. */ @@ -68,8 +79,10 @@ export default class ComponentInteraction client.util.updateEntitlement(entitlement)) ?? []; this.guildID = (data.guild_id ?? null) as T extends AnyTextableGuildChannel ? string : string | null; this.guildLocale = data.guild_locale as T extends AnyTextableGuildChannel ? string : string | undefined; @@ -334,15 +347,17 @@ export default class ComponentInteraction extends Interaction { private _cachedChannel!: T extends AnyInteractionChannel ? T : undefined; private _cachedGuild?: T extends AnyTextableGuildChannel ? Guild : Guild | null; - /** The permissions the bot has in the channel this interaction was sent from, if this interaction is sent from a guild. */ - appPermissions: T extends AnyTextableGuildChannel ? Permission : Permission | undefined; + /** The permissions the bot has in the channel this interaction was sent from. If in a dm/group dm, this will contain `ATTACH_FILES`, `EMBED_LINKS`, and `MENTION_EVERYONE`. In addition, `USE_EXTERNAL_EMOJIS` will be included for DMs with the app's bot user. */ + appPermissions: Permission; + /** Details about the authorizing user or server for the installation(s) relevant to the interaction. See [Discord's docs](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-authorizing-integration-owners-object) for more information. */ + authorizingIntegrationOwners: AuthorizingIntegrationOwners; /** The ID of the channel this interaction was sent from. */ channelID: string; + /** The context this interaction was sent from. */ + context?: InteractionContextTypes; /** The data associated with the interaction. */ data: ModalSubmitInteractionData; /** The entitlements for the user that created this interaction, and the guild it was created in. */ @@ -60,8 +65,10 @@ export default class ModalSubmitInteraction; + /** The configs for the install types available for this application. */ + integrationTypesConfig: IntegrationTypesConfig; /** The name of the application. */ name: string; /** The owner of this application. */ @@ -67,6 +71,8 @@ export default class OAuthApplication extends Base { this.flags = data.flags; this.guildID = data.guild_id ?? null; this.icon = null; + this.integrationTypes = []; + this.integrationTypesConfig = {}; this.name = data.name; this.owner = client.users.update(data.owner); this.ownerID = data.owner.id; @@ -104,6 +110,12 @@ export default class OAuthApplication extends Base { if (data.install_params !== undefined) { this.installParams = data.install_params; } + if (data.integration_types !== undefined) { + this.integrationTypes = data.integration_types; + } + if (data.integration_types_config !== undefined) { + this.integrationTypesConfig = Object.fromEntries(Object.entries(data.integration_types_config).map(([key, value]) => [key, { oauth2InstallParams: value.oauth2_install_params }])); + } if (data.name !== undefined) { this.name = data.name; } @@ -183,27 +195,29 @@ export default class OAuthApplication extends Base { override toJSON(): JSONOAuthApplication { return { ...super.toJSON(), - botPublic: this.botPublic, - botRequireCodeGrant: this.botRequireCodeGrant, - coverImage: this.coverImage, - customInstallURL: this.customInstallURL, - description: this.description, - flags: this.flags, - guildID: this.guildID, - icon: this.icon, - installParams: this.installParams, - name: this.name, - owner: this.owner.toJSON(), - ownerID: this.ownerID, - primarySKUID: this.primarySKUID, - privacyPolicyURL: this.privacyPolicyURL, - rpcOrigins: this.rpcOrigins, - slug: this.slug, - tags: this.tags, - team: this.team?.toJSON() ?? null, - termsOfServiceURL: this.termsOfServiceURL, - type: this.type, - verifyKey: this.verifyKey + botPublic: this.botPublic, + botRequireCodeGrant: this.botRequireCodeGrant, + coverImage: this.coverImage, + customInstallURL: this.customInstallURL, + description: this.description, + flags: this.flags, + guildID: this.guildID, + icon: this.icon, + installParams: this.installParams, + integrationTypes: this.integrationTypes, + integrationTypesConfig: this.integrationTypesConfig, + name: this.name, + owner: this.owner.toJSON(), + ownerID: this.ownerID, + primarySKUID: this.primarySKUID, + privacyPolicyURL: this.privacyPolicyURL, + rpcOrigins: this.rpcOrigins, + slug: this.slug, + tags: this.tags, + team: this.team?.toJSON() ?? null, + termsOfServiceURL: this.termsOfServiceURL, + type: this.type, + verifyKey: this.verifyKey }; } diff --git a/lib/structures/Webhook.ts b/lib/structures/Webhook.ts index bf62afa0..961cf966 100644 --- a/lib/structures/Webhook.ts +++ b/lib/structures/Webhook.ts @@ -149,9 +149,8 @@ export default class Webhook extends Base { /** * Edit a webhook message. - * @param id The ID of the webhook. - * @param token The token of the webhook. * @param messageID The ID of the message to edit. + * @param token The token of the webhook. * @param options The options for editing the message. */ async editMessage(messageID: string, options: EditWebhookMessageOptions, token?: string): Promise> { diff --git a/lib/types/applications.d.ts b/lib/types/applications.d.ts index 4d905229..6e765179 100644 --- a/lib/types/applications.d.ts +++ b/lib/types/applications.d.ts @@ -6,8 +6,10 @@ import type { ApplicationCommandOptionTypes, ApplicationCommandPermissionTypes, ApplicationCommandTypes, + ApplicationIntegrationTypes, EntitlementOwnerTypes, EntitlementTypes, + InteractionContextTypes, SKUAccessTypes, SKUTypes, TeamMembershipState @@ -30,6 +32,8 @@ export interface RawApplication { icon: string | null; id: string; install_params?: InstallParams; + integration_types?: Array; + integration_types_config?: Partial>; interactions_endpoint_url?: string | null; name: string; owner?: RawUser; @@ -39,7 +43,6 @@ export interface RawApplication { role_connections_verification_url?: string | null; rpc_origins?: Array; slug?: string; - // summary is deprecated and being removed in v11 tags?: Array; team?: RawTeam | null; terms_of_service_url?: string; @@ -48,11 +51,21 @@ export interface RawApplication { } export interface RawPartialApplication extends Pick, Partial> {} -export interface RESTOAuthApplication extends WithRequired {} -export interface RESTApplication extends WithRequired {} +export interface RESTOAuthApplication extends WithRequired {} +export interface RESTApplication extends WithRequired {} export interface RawClientApplication extends Required> {} export type TeamMemberRoleTypes = "admin" | "developer" | "read-only"; +export interface IntegrationTypesConfig extends Partial> {} + +export interface RawApplicationIntegrationConfig { + oauth2_install_params?: InstallParams; +} + +export interface ApplicationIntegrationConfig { + oauth2InstallParams?: InstallParams; +} + export interface RawTeam { icon: string | null; id: string; @@ -81,6 +94,7 @@ export interface TeamMember { export interface RawApplicationCommand { application_id: string; + contexts: Array; default_member_permissions: string | null; description: string; description_localizations?: LocaleMap | null; @@ -88,6 +102,7 @@ export interface RawApplicationCommand { dm_permission?: boolean; guild_id?: string; id: string; + integration_types: Array; name: string; name_localizations?: LocaleMap | null; name_localized?: string; @@ -221,12 +236,19 @@ export interface ApplicationCommandOptionsUser extends ApplicationCommandOptionB // desc, options export interface CreateApplicationCommandOptionsBase { + /** The interaction contexts where the command can be used. Defaults to all interaction context types for new commands. */ + contexts?: Array; /** The default member permissions for the command. */ defaultMemberPermissions?: string | null; - /** If the command can be used in a DM. */ + /** + * If the command can be used in a DM. + * @deprecated Use contexts instead. + */ dmPermission?: boolean | null; /** The ID of the command, if known. (Only usable when bulkEditing guild commands.) */ id?: string; + /** The install contexts where the command is available. Defaults to {@link Constants~ApplicationIntegrationTypes.GUILD_INSTALL | GUILD_INSTALL}. */ + integrationTypes?: Array; /** The name of the command. */ name: string; /** A dictionary of [locales](https://discord.com/developers/docs/reference#locales) to localized names. */ @@ -238,9 +260,9 @@ export interface CreateApplicationCommandOptionsBase {} -export interface CreateGuildUserApplicationCommandOptions extends Omit {} -export interface CreateGuildMessageApplicationCommandOptions extends Omit {} +export interface CreateGuildChatInputApplicationCommandOptions extends Omit {} +export interface CreateGuildUserApplicationCommandOptions extends Omit {} +export interface CreateGuildMessageApplicationCommandOptions extends Omit {} export type CreateGuildApplicationCommandOptions = CreateGuildChatInputApplicationCommandOptions | CreateGuildUserApplicationCommandOptions | CreateGuildMessageApplicationCommandOptions; export interface CreateChatInputApplicationCommandOptions extends CreateApplicationCommandOptionsBase { /** The description of the command. */ @@ -260,9 +282,9 @@ export interface EditUserApplicationCommandOptions extends Partial> {} export type EditGuildApplicationCommandOptions = EditGuildChatInputApplicationCommandOptions | EditGuildUserApplicationCommandOptions | EditGuildMessageApplicationCommandOptions; -export interface EditGuildChatInputApplicationCommandOptions extends Partial> {} -export interface EditGuildUserApplicationCommandOptions extends Partial> {} -export interface EditGuildMessageApplicationCommandOptions extends Partial> {} +export interface EditGuildChatInputApplicationCommandOptions extends Partial> {} +export interface EditGuildUserApplicationCommandOptions extends Partial> {} +export interface EditGuildMessageApplicationCommandOptions extends Partial> {} export interface RawGuildApplicationCommandPermissions { application_id: string; @@ -416,6 +438,7 @@ export interface EditApplicationOptions { icon?: string | Buffer | null; /** The install parameters of the application. */ installParams?: InstallParams; + integrationTypesConfig?: IntegrationTypesConfig; /** The url where the application receives interactions. Must be valid according to Discord's [Receiving an interaction](https://discord.com/developers/docs/interactions/receiving-and-responding#receiving-an-interaction) documentation. */ interactionsEndpointURL?: string; /** The role connection verification url for the application. */ diff --git a/lib/types/channels.d.ts b/lib/types/channels.d.ts index 12c3ede9..fe4c41a4 100644 --- a/lib/types/channels.d.ts +++ b/lib/types/channels.d.ts @@ -5,7 +5,7 @@ import type { RawUser, RawUserWithMember } from "./users"; import type { File } from "./request-handler"; import type { RawScheduledEvent } from "./scheduled-events"; import { type Uncached } from "./shared"; -import type { SelectMenuDefaultValue } from "./interactions"; +import type { AuthorizingIntegrationOwners, SelectMenuDefaultValue } from "./interactions"; import type { ButtonStyles, ChannelTypes, @@ -671,7 +671,9 @@ export interface RawMessage { flags?: number; guild_id?: string; id: string; + /** @deprecated */ interaction?: RawMessageInteraction; + interaction_metadata?: RawMessageInteractionMetadata; member?: RawMember; mention_channels?: Array; mention_everyone: boolean; @@ -744,6 +746,7 @@ export interface RawMessageInteraction { user: RawUser; } +/** @deprecated */ export interface MessageInteraction { id: string; member?: Member; @@ -752,6 +755,26 @@ export interface MessageInteraction { user: User; } +export interface RawMessageInteractionMetadata { + authorizing_integration_owners: AuthorizingIntegrationOwners; + id: string; + interacted_message_id?: string; + original_response_message_id?: string; + triggering_interaction_metadata?: Omit; + type: InteractionTypes; + user_id: string; +} + +export interface MessageInteractionMetadata { + authorizingIntegrationOwners: AuthorizingIntegrationOwners; + id: string; + interactedMessageID?: string; + originalResponseMessageID?: string; + triggeringInteractionMetadata?: Omit; + type: InteractionTypes; + user: User | Uncached; +} + export interface StickerItem { format_type: StickerFormatTypes; diff --git a/lib/types/interactions.d.ts b/lib/types/interactions.d.ts index 196e0751..f04f423d 100644 --- a/lib/types/interactions.d.ts +++ b/lib/types/interactions.d.ts @@ -16,8 +16,10 @@ import type { LocaleMap, RawEntitlement, RawTestEntitlement } from "./applicatio import type { ApplicationCommandOptionTypes, ApplicationCommandTypes, + ApplicationIntegrationTypes, ComponentTypes, GuildFeature, + InteractionContextTypes, InteractionResponseTypes, InteractionTypes, MessageComponentTypes, @@ -94,9 +96,11 @@ export interface ModalData { } export interface RawInteraction { - app_permissions?: string; + app_permissions: string; application_id: string; + authorizing_integration_owners: AuthorizingIntegrationOwners; channel_id?: string; + context?: InteractionContextTypes; data?: RawInteractionData; entitlements?: Array; guild?: InteractionGuild; @@ -112,6 +116,8 @@ export interface RawInteraction { version: 1; } +export interface AuthorizingIntegrationOwners extends Partial> {} + export type AnyRawInteraction = RawPingInteraction | AnyRawGatewayInteraction; export type AnyRawGatewayInteraction = RawApplicationCommandInteraction | RawMessageComponentInteraction | RawAutocompleteInteraction | RawModalSubmitInteraction; export interface RawPingInteraction extends Pick {} @@ -267,8 +273,7 @@ export interface AutocompleteChoice { value: string; } -type Guildify = Omit & { - appPermissions: Permission; +type Guildify = Omit & { guild: Guild; guildID: string; guildLocale: string; @@ -276,8 +281,7 @@ type Guildify = Omit = Omit & { - appPermissions: undefined; +type Privatify = Omit & { guild: undefined; guildID: undefined; guildLocale: undefined; diff --git a/lib/types/json.d.ts b/lib/types/json.d.ts index 5e386b1f..018826a0 100644 --- a/lib/types/json.d.ts +++ b/lib/types/json.d.ts @@ -1,9 +1,10 @@ /** @module Types/JSON */ /* eslint-disable @typescript-eslint/no-empty-interface */ import type { InstallParams } from "./oauth"; -import type { ApplicationCommandOptions, LocaleMap, TeamMember } from "./applications"; +import type { ApplicationCommandOptions, IntegrationTypesConfig, LocaleMap, TeamMember } from "./applications"; import type { ApplicationCommandInteractionData, + AuthorizingIntegrationOwners, AutocompleteInteractionData, MessageComponentButtonInteractionData, MessageComponentSelectMenuInteractionData, @@ -41,6 +42,7 @@ import type { ThreadOnlyChannels } from "./channels"; import type { ScheduledEventEntityMetadata } from "./scheduled-events"; +import type { Uncached } from "./shared"; import type { ApplicationCommandTypes, AutoModerationEventTypes, @@ -69,7 +71,9 @@ import type { SortOrderTypes, StageInstancePrivacyLevels, ForumLayoutTypes, - EntitlementTypes + EntitlementTypes, + ApplicationIntegrationTypes, + InteractionContextTypes } from "../Constants"; export interface JSONAnnouncementChannel extends JSONThreadableChannel { @@ -89,6 +93,8 @@ export interface JSONApplication extends JSONClientApplication { guildID: string | null; icon: string | null; installParams?: InstallParams; + integrationTypes: Array; + integrationTypesConfig?: IntegrationTypesConfig; interactionsEndpointURL: string | null; name: string; primarySKUID?: string; @@ -103,11 +109,13 @@ export interface JSONApplication extends JSONClientApplication { } export interface JSONApplicationCommand extends JSONBase { applicationID: string; + contexts: Array; defaultMemberPermissions?: JSONPermission; description: string; descriptionLocalizations?: LocaleMap | null; dmPermission?: boolean; guildID?: string; + integrationTypes: Array; name: string; nameLocalizations?: LocaleMap | null; nsfw?: boolean; @@ -128,8 +136,12 @@ export interface JSONAttachment extends JSONBase { width?: number; } export interface JSONAutocompleteInteraction extends JSONInteraction { - appPermissions?: JSONPermission; + appPermissions: JSONPermission; + authorizingIntegrationOwners: AuthorizingIntegrationOwners; + /** @deprecated Use {@link JSONAutocompleteInteraction#channelID | channelID}. This will be removed in `1.10.0`. */ channel: string; + channelID: string; + context?: InteractionContextTypes; data: AutocompleteInteractionData; guildID?: string; guildLocale?: string; @@ -185,8 +197,10 @@ export interface JSONClientUser extends JSONUser { verified: boolean; } export interface JSONCommandInteraction extends JSONInteraction { - appPermissions?: JSONPermission; + appPermissions: JSONPermission; + authorizingIntegrationOwners: AuthorizingIntegrationOwners; channelID: string; + context?: InteractionContextTypes; data: ApplicationCommandInteractionData; guildID?: string; guildLocale?: string; @@ -196,8 +210,10 @@ export interface JSONCommandInteraction extends JSONInteraction { user: JSONUser; } export interface JSONComponentInteraction extends JSONInteraction { - appPermissions?: JSONPermission; + appPermissions: JSONPermission; + authorizingIntegrationOwners: AuthorizingIntegrationOwners; channelID: string; + context?: InteractionContextTypes; data: MessageComponentButtonInteractionData | MessageComponentSelectMenuInteractionData; guildID?: string; guildLocale?: string; @@ -425,6 +441,22 @@ export interface JSONMessage extends JSONBase { type: InteractionTypes; user: JSONUser; }; + interactionMetadata?: { + authorizingIntegrationOwners: AuthorizingIntegrationOwners; + id: string; + interactedMessageID?: string; + originalResponseMessageID?: string; + triggeringInteractionMetadata?: { + authorizingIntegrationOwners: AuthorizingIntegrationOwners; + id: string; + interactedMessageID?: string; + originalResponseMessageID?: string; + type: InteractionTypes; + user: JSONUser | Uncached; + }; + type: InteractionTypes; + user: JSONUser | Uncached; + }; mentionChannels?: Array; mentions: { channels: Array; @@ -447,8 +479,10 @@ export interface JSONMessage extends JSONBase { webhook?: string; } export interface JSONModalSubmitInteraction extends JSONInteraction { - appPermissions?: JSONPermission; + appPermissions: JSONPermission; + authorizingIntegrationOwners: AuthorizingIntegrationOwners; channelID: string; + context?: InteractionContextTypes; data: ModalSubmitInteractionData; guildID?: string; guildLocale?: string; @@ -467,6 +501,8 @@ export interface JSONOAuthApplication extends JSONBase { guildID: string | null; icon: string | null; installParams?: InstallParams; + integrationTypes: Array; + integrationTypesConfig?: IntegrationTypesConfig; name: string; owner: JSONUser; ownerID: string;