From 198fcea1a608ad46cdc9411cb774307761f62661 Mon Sep 17 00:00:00 2001 From: imnaiyar <137700126+imnaiyar@users.noreply.github.com> Date: Fri, 1 Nov 2024 12:48:18 -0500 Subject: [PATCH 1/7] feat(ClientApplication): add webhook events --- .../src/structures/ClientApplication.js | 39 +++++++++++++++++++ packages/discord.js/typings/index.d.ts | 8 ++++ 2 files changed, 47 insertions(+) diff --git a/packages/discord.js/src/structures/ClientApplication.js b/packages/discord.js/src/structures/ClientApplication.js index 3149a579381a..5971e541774e 100644 --- a/packages/discord.js/src/structures/ClientApplication.js +++ b/packages/discord.js/src/structures/ClientApplication.js @@ -236,6 +236,36 @@ class ClientApplication extends Application { this.roleConnectionsVerificationURL ??= null; } + if ('event_webhooks_url' in data) { + /** + * This application's event webhooks URL + * @type {?string} + */ + this.eventWebhooksURL = data.event_webhooks_url; + } else { + this.eventWebhooksURL ??= null; + } + + if ('event_webhooks_status' in data) { + /** + * This application's event webhooks status + * @type {?ApplicationEventWebhookStatus} + */ + this.eventWebhooksStatus = data.event_webhooks_status; + } else { + this.eventWebhooksStatus ??= null; + } + + if ('event_webhooks_types' in data) { + /** + * This application's event webhooks types + * @type {?WebhookEventType[]} + */ + this.eventWebhooksTypes = data.event_webhooks_types; + } else { + this.eventWebhooksTypes ??= null; + } + /** * The owner of this OAuth application * @type {?(User|Team)} @@ -277,6 +307,9 @@ class ClientApplication extends Application { * @property {?(BufferResolvable|Base64Resolvable)} [icon] The application's icon * @property {?(BufferResolvable|Base64Resolvable)} [coverImage] The application's cover image * @property {string} [interactionsEndpointURL] The application's interaction endpoint URL + * @property {string} [eventWebhooksURL] The application's event webhooks URL + * @property {ApplicationEventWebhookStatus} [eventWebhooksStatus] The application's event webhooks status + * @property {WebhookEventType[]} [eventWebhooksTypes] The application's event webhooks types * @property {string[]} [tags] The application's tags */ @@ -294,6 +327,9 @@ class ClientApplication extends Application { icon, coverImage, interactionsEndpointURL, + eventWebhooksURL, + eventWebhooksStatus, + eventWebhooksTypes, tags, } = {}) { const data = await this.client.rest.patch(Routes.currentApplication(), { @@ -306,6 +342,9 @@ class ClientApplication extends Application { icon: icon && (await resolveImage(icon)), cover_image: coverImage && (await resolveImage(coverImage)), interactions_endpoint_url: interactionsEndpointURL, + event_webhooks_url: eventWebhooksURL, + event_webhooks_status: eventWebhooksStatus, + event_webhooks_types: eventWebhooksTypes, tags, }, }); diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index ac5df23cbcfc..c48380e992de 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -166,6 +166,8 @@ import { GuildScheduledEventRecurrenceRuleFrequency, GatewaySendPayload, GatewayDispatchPayload, + ApplicationEventWebhookStatus, + WebhookEventType, VoiceChannelEffectSendAnimationType, GatewayVoiceChannelEffectSendDispatchData, } from 'discord-api-types/v10'; @@ -1066,6 +1068,9 @@ export class ClientApplication extends Application { public owner: User | Team | null; public get partial(): boolean; public interactionsEndpointURL: string | null; + public eventWebhookURL: string | null; + public eventWebhooksStatus: ApplicationEventWebhookStatus | null; + public eventWebhooksTypes: WebhookEventType[] | null; public roleConnectionsVerificationURL: string | null; public rpcOrigins: string[]; public edit(options: ClientApplicationEditOptions): Promise; @@ -6871,6 +6876,9 @@ export interface ClientApplicationEditOptions { icon?: BufferResolvable | Base64Resolvable | null; coverImage?: BufferResolvable | Base64Resolvable | null; interactionsEndpointURL?: string; + eventWebhooksURL?: string; + eventWebhooksStatus?: ApplicationEventWebhookStatus; + eventWebhooksTypes?: WebhookEventType[]; tags?: readonly string[]; } From 55f41dbd753bd41806c757312ef1df05607beb73 Mon Sep 17 00:00:00 2001 From: imnaiyar <137700126+imnaiyar@users.noreply.github.com> Date: Thu, 21 Nov 2024 07:14:45 -0600 Subject: [PATCH 2/7] refactor: update enum names and add external types --- .../discord.js/src/structures/ClientApplication.js | 8 ++++---- packages/discord.js/src/util/APITypes.js | 10 ++++++++++ packages/discord.js/typings/index.d.ts | 12 ++++++------ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/discord.js/src/structures/ClientApplication.js b/packages/discord.js/src/structures/ClientApplication.js index 5971e541774e..a9dc88aff448 100644 --- a/packages/discord.js/src/structures/ClientApplication.js +++ b/packages/discord.js/src/structures/ClientApplication.js @@ -249,7 +249,7 @@ class ClientApplication extends Application { if ('event_webhooks_status' in data) { /** * This application's event webhooks status - * @type {?ApplicationEventWebhookStatus} + * @type {?ApplicationWebhookEventStatus} */ this.eventWebhooksStatus = data.event_webhooks_status; } else { @@ -259,7 +259,7 @@ class ClientApplication extends Application { if ('event_webhooks_types' in data) { /** * This application's event webhooks types - * @type {?WebhookEventType[]} + * @type {?ApplicationWebhookEventType[]} */ this.eventWebhooksTypes = data.event_webhooks_types; } else { @@ -308,8 +308,8 @@ class ClientApplication extends Application { * @property {?(BufferResolvable|Base64Resolvable)} [coverImage] The application's cover image * @property {string} [interactionsEndpointURL] The application's interaction endpoint URL * @property {string} [eventWebhooksURL] The application's event webhooks URL - * @property {ApplicationEventWebhookStatus} [eventWebhooksStatus] The application's event webhooks status - * @property {WebhookEventType[]} [eventWebhooksTypes] The application's event webhooks types + * @property {ApplicationWebhookEventStatus} [eventWebhooksStatus] The application's event webhooks status + * @property {ApplicationWebhookEventType[]} [eventWebhooksTypes] The application's event webhooks types * @property {string[]} [tags] The application's tags */ diff --git a/packages/discord.js/src/util/APITypes.js b/packages/discord.js/src/util/APITypes.js index 92495107c01b..322b68da94e5 100644 --- a/packages/discord.js/src/util/APITypes.js +++ b/packages/discord.js/src/util/APITypes.js @@ -603,3 +603,13 @@ * @external WebhookType * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/WebhookType} */ + +/** + * @external ApplicationWebhookEventStatus + * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationWebhookEventStatus} + */ + +/** + * @external ApplicationWebhookEventType + * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationWebhookEventType} + */ diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index c48380e992de..9bcc132f0f99 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -166,8 +166,8 @@ import { GuildScheduledEventRecurrenceRuleFrequency, GatewaySendPayload, GatewayDispatchPayload, - ApplicationEventWebhookStatus, - WebhookEventType, + ApplicationWebhookEventStatus, + ApplicationWebhookEventType, VoiceChannelEffectSendAnimationType, GatewayVoiceChannelEffectSendDispatchData, } from 'discord-api-types/v10'; @@ -1069,8 +1069,8 @@ export class ClientApplication extends Application { public get partial(): boolean; public interactionsEndpointURL: string | null; public eventWebhookURL: string | null; - public eventWebhooksStatus: ApplicationEventWebhookStatus | null; - public eventWebhooksTypes: WebhookEventType[] | null; + public eventWebhooksStatus: ApplicationWebhookEventStatus | null; + public eventWebhooksTypes: ApplicationWebhookEventType[] | null; public roleConnectionsVerificationURL: string | null; public rpcOrigins: string[]; public edit(options: ClientApplicationEditOptions): Promise; @@ -6877,8 +6877,8 @@ export interface ClientApplicationEditOptions { coverImage?: BufferResolvable | Base64Resolvable | null; interactionsEndpointURL?: string; eventWebhooksURL?: string; - eventWebhooksStatus?: ApplicationEventWebhookStatus; - eventWebhooksTypes?: WebhookEventType[]; + eventWebhooksStatus?: ApplicationWebhookEventStatus; + eventWebhooksTypes?: readonly ApplicationWebhookEventType[]; tags?: readonly string[]; } From 4a1f8526043376737a8013f0fb89c79866b9fb86 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:02:25 +0000 Subject: [PATCH 3/7] docs(APITypes): reorder --- packages/discord.js/src/util/APITypes.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/discord.js/src/util/APITypes.js b/packages/discord.js/src/util/APITypes.js index 322b68da94e5..aab5f3cafea8 100644 --- a/packages/discord.js/src/util/APITypes.js +++ b/packages/discord.js/src/util/APITypes.js @@ -255,6 +255,16 @@ * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationRoleConnectionMetadataType} */ +/** + * @external ApplicationWebhookEventStatus + * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationWebhookEventStatus} + */ + +/** + * @external ApplicationWebhookEventType + * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationWebhookEventType} + */ + /** * @external AttachmentFlags * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/AttachmentFlags} @@ -603,13 +613,3 @@ * @external WebhookType * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/WebhookType} */ - -/** - * @external ApplicationWebhookEventStatus - * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationWebhookEventStatus} - */ - -/** - * @external ApplicationWebhookEventType - * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationWebhookEventType} - */ From f81f6d99967f3ea466a888687a8506ca0ffadfef Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:17:23 +0000 Subject: [PATCH 4/7] chore: requested changes --- packages/discord.js/src/structures/ClientApplication.js | 7 ++++--- packages/discord.js/typings/index.d.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/discord.js/src/structures/ClientApplication.js b/packages/discord.js/src/structures/ClientApplication.js index ea0398956a45..a756c4683243 100644 --- a/packages/discord.js/src/structures/ClientApplication.js +++ b/packages/discord.js/src/structures/ClientApplication.js @@ -245,7 +245,7 @@ class ClientApplication extends Application { if ('event_webhooks_url' in data) { /** - * This application's event webhooks URL + * This application's URL to receive event webhooks * @type {?string} */ this.eventWebhooksURL = data.event_webhooks_url; @@ -265,7 +265,7 @@ class ClientApplication extends Application { if ('event_webhooks_types' in data) { /** - * This application's event webhooks types + * List of event webhooks types this application subscribes to * @type {?ApplicationWebhookEventType[]} */ this.eventWebhooksTypes = data.event_webhooks_types; @@ -315,7 +315,8 @@ class ClientApplication extends Application { * @property {?(BufferResolvable|Base64Resolvable)} [coverImage] The application's cover image * @property {string} [interactionsEndpointURL] The application's interaction endpoint URL * @property {string} [eventWebhooksURL] The application's event webhooks URL - * @property {ApplicationWebhookEventStatus} [eventWebhooksStatus] The application's event webhooks status + * @property {ApplicationWebhookEventStatus} [eventWebhooksStatus] The application's event webhooks status. + * Only {@link ApplicationWebhookEventStatus.Enabled} and {@link ApplicationWebhookEventStatus.Disabled} can be set. * @property {ApplicationWebhookEventType[]} [eventWebhooksTypes] The application's event webhooks types * @property {string[]} [tags] The application's tags */ diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index f5d1f1aabbbb..adfee8eaf493 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1083,7 +1083,7 @@ export class ClientApplication extends Application { public owner: User | Team | null; public get partial(): boolean; public interactionsEndpointURL: string | null; - public eventWebhookURL: string | null; + public eventWebhooksURL: string | null; public eventWebhooksStatus: ApplicationWebhookEventStatus | null; public eventWebhooksTypes: ApplicationWebhookEventType[] | null; public roleConnectionsVerificationURL: string | null; From cea27a9e5c8c97440c03390dda504e94d4cd3c60 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:34:36 +0000 Subject: [PATCH 5/7] chore: requested changes --- packages/discord.js/src/structures/ClientApplication.js | 3 ++- packages/discord.js/typings/index.d.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/discord.js/src/structures/ClientApplication.js b/packages/discord.js/src/structures/ClientApplication.js index a756c4683243..9114859aac1c 100644 --- a/packages/discord.js/src/structures/ClientApplication.js +++ b/packages/discord.js/src/structures/ClientApplication.js @@ -315,7 +315,8 @@ class ClientApplication extends Application { * @property {?(BufferResolvable|Base64Resolvable)} [coverImage] The application's cover image * @property {string} [interactionsEndpointURL] The application's interaction endpoint URL * @property {string} [eventWebhooksURL] The application's event webhooks URL - * @property {ApplicationWebhookEventStatus} [eventWebhooksStatus] The application's event webhooks status. + * @property {ApplicationWebhookEventStatus.Enabled|ApplicationWebhookEventStatus.Disabled} [eventWebhooksStatus] + * The application's event webhooks status. * Only {@link ApplicationWebhookEventStatus.Enabled} and {@link ApplicationWebhookEventStatus.Disabled} can be set. * @property {ApplicationWebhookEventType[]} [eventWebhooksTypes] The application's event webhooks types * @property {string[]} [tags] The application's tags diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 8059b7abecae..c4d5d22ed2b9 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -6978,7 +6978,7 @@ export interface ClientApplicationEditOptions { coverImage?: BufferResolvable | Base64Resolvable | null; interactionsEndpointURL?: string; eventWebhooksURL?: string; - eventWebhooksStatus?: ApplicationWebhookEventStatus; + eventWebhooksStatus?: ApplicationWebhookEventStatus.Enabled | ApplicationWebhookEventStatus.Disabled; eventWebhooksTypes?: readonly ApplicationWebhookEventType[]; tags?: readonly string[]; } From fdfb0fbe6ad29051a2bee6f5d8383eda0927a1bf Mon Sep 17 00:00:00 2001 From: Almeida Date: Thu, 5 Dec 2024 18:46:33 +0000 Subject: [PATCH 6/7] docs: remove redundancy --- packages/discord.js/src/structures/ClientApplication.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/discord.js/src/structures/ClientApplication.js b/packages/discord.js/src/structures/ClientApplication.js index 9114859aac1c..425ca82b8eb4 100644 --- a/packages/discord.js/src/structures/ClientApplication.js +++ b/packages/discord.js/src/structures/ClientApplication.js @@ -79,7 +79,7 @@ class ClientApplication extends Application { * OAuth2 installation parameters. * @typedef {Object} IntegrationTypesConfigurationParameters * @property {OAuth2Scopes[]} scopes Scopes that will be set upon adding this application - * @property {Readonly} permissions Permissions that will be requested for the integrated role + * @property {Read} permissions Permissions that will be requested for the integrated role */ /** @@ -287,7 +287,7 @@ class ClientApplication extends Application { /** * The guild associated with this application. * @type {?Guild} - * @readonly + * @read */ get guild() { return this.client.guilds.cache.get(this.guildId) ?? null; @@ -296,7 +296,7 @@ class ClientApplication extends Application { /** * Whether this application is partial * @type {boolean} - * @readonly + * @read */ get partial() { return !this.name; @@ -317,7 +317,6 @@ class ClientApplication extends Application { * @property {string} [eventWebhooksURL] The application's event webhooks URL * @property {ApplicationWebhookEventStatus.Enabled|ApplicationWebhookEventStatus.Disabled} [eventWebhooksStatus] * The application's event webhooks status. - * Only {@link ApplicationWebhookEventStatus.Enabled} and {@link ApplicationWebhookEventStatus.Disabled} can be set. * @property {ApplicationWebhookEventType[]} [eventWebhooksTypes] The application's event webhooks types * @property {string[]} [tags] The application's tags */ From ef69cd49e8e5de2d4c365a253befc9227cf3d16a Mon Sep 17 00:00:00 2001 From: Almeida Date: Thu, 5 Dec 2024 18:47:49 +0000 Subject: [PATCH 7/7] Update ClientApplication.js --- packages/discord.js/src/structures/ClientApplication.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/discord.js/src/structures/ClientApplication.js b/packages/discord.js/src/structures/ClientApplication.js index 425ca82b8eb4..ee7dea261bc0 100644 --- a/packages/discord.js/src/structures/ClientApplication.js +++ b/packages/discord.js/src/structures/ClientApplication.js @@ -79,7 +79,7 @@ class ClientApplication extends Application { * OAuth2 installation parameters. * @typedef {Object} IntegrationTypesConfigurationParameters * @property {OAuth2Scopes[]} scopes Scopes that will be set upon adding this application - * @property {Read} permissions Permissions that will be requested for the integrated role + * @property {Readonly} permissions Permissions that will be requested for the integrated role */ /** @@ -287,7 +287,7 @@ class ClientApplication extends Application { /** * The guild associated with this application. * @type {?Guild} - * @read + * @readonly */ get guild() { return this.client.guilds.cache.get(this.guildId) ?? null; @@ -296,7 +296,7 @@ class ClientApplication extends Application { /** * Whether this application is partial * @type {boolean} - * @read + * @readonly */ get partial() { return !this.name;