feat(ClientApplication): add webhook events (#10588)

* feat(ClientApplication): add webhook events

* refactor: update enum names and add external types

* docs(APITypes): reorder

* chore: requested changes

* chore: requested changes

* docs: remove redundancy

* Update ClientApplication.js

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: Almeida <github@almeidx.dev>
This commit is contained in:
Naiyar
2024-12-06 00:22:02 +05:30
committed by Jiralite
parent a367e2c8c9
commit ae1deac2bf
3 changed files with 58 additions and 0 deletions

View File

@@ -243,6 +243,36 @@ class ClientApplication extends Application {
this.roleConnectionsVerificationURL ??= null; this.roleConnectionsVerificationURL ??= null;
} }
if ('event_webhooks_url' in data) {
/**
* This application's URL to receive event webhooks
* @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 {?ApplicationWebhookEventStatus}
*/
this.eventWebhooksStatus = data.event_webhooks_status;
} else {
this.eventWebhooksStatus ??= null;
}
if ('event_webhooks_types' in data) {
/**
* List of event webhooks types this application subscribes to
* @type {?ApplicationWebhookEventType[]}
*/
this.eventWebhooksTypes = data.event_webhooks_types;
} else {
this.eventWebhooksTypes ??= null;
}
/** /**
* The owner of this OAuth application * The owner of this OAuth application
* @type {?(User|Team)} * @type {?(User|Team)}
@@ -284,6 +314,10 @@ class ClientApplication extends Application {
* @property {?(BufferResolvable|Base64Resolvable)} [icon] The application's icon * @property {?(BufferResolvable|Base64Resolvable)} [icon] The application's icon
* @property {?(BufferResolvable|Base64Resolvable)} [coverImage] The application's cover image * @property {?(BufferResolvable|Base64Resolvable)} [coverImage] The application's cover image
* @property {string} [interactionsEndpointURL] The application's interaction endpoint URL * @property {string} [interactionsEndpointURL] The application's interaction endpoint URL
* @property {string} [eventWebhooksURL] The application's event webhooks URL
* @property {ApplicationWebhookEventStatus.Enabled|ApplicationWebhookEventStatus.Disabled} [eventWebhooksStatus]
* The application's event webhooks status.
* @property {ApplicationWebhookEventType[]} [eventWebhooksTypes] The application's event webhooks types
* @property {string[]} [tags] The application's tags * @property {string[]} [tags] The application's tags
*/ */
@@ -301,6 +335,9 @@ class ClientApplication extends Application {
icon, icon,
coverImage, coverImage,
interactionsEndpointURL, interactionsEndpointURL,
eventWebhooksURL,
eventWebhooksStatus,
eventWebhooksTypes,
tags, tags,
} = {}) { } = {}) {
const data = await this.client.rest.patch(Routes.currentApplication(), { const data = await this.client.rest.patch(Routes.currentApplication(), {
@@ -313,6 +350,9 @@ class ClientApplication extends Application {
icon: icon && (await resolveImage(icon)), icon: icon && (await resolveImage(icon)),
cover_image: coverImage && (await resolveImage(coverImage)), cover_image: coverImage && (await resolveImage(coverImage)),
interactions_endpoint_url: interactionsEndpointURL, interactions_endpoint_url: interactionsEndpointURL,
event_webhooks_url: eventWebhooksURL,
event_webhooks_status: eventWebhooksStatus,
event_webhooks_types: eventWebhooksTypes,
tags, tags,
}, },
}); });

View File

@@ -255,6 +255,16 @@
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationRoleConnectionMetadataType} * @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 * @external AttachmentFlags
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/AttachmentFlags} * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/AttachmentFlags}

View File

@@ -191,6 +191,8 @@ import {
GuildScheduledEventRecurrenceRuleFrequency, GuildScheduledEventRecurrenceRuleFrequency,
APISubscription, APISubscription,
SubscriptionStatus, SubscriptionStatus,
ApplicationWebhookEventStatus,
ApplicationWebhookEventType,
VoiceChannelEffectSendAnimationType, VoiceChannelEffectSendAnimationType,
GatewayVoiceChannelEffectSendDispatchData, GatewayVoiceChannelEffectSendDispatchData,
} from 'discord-api-types/v10'; } from 'discord-api-types/v10';
@@ -1097,6 +1099,9 @@ export class ClientApplication extends Application {
public owner: User | Team | null; public owner: User | Team | null;
public get partial(): boolean; public get partial(): boolean;
public interactionsEndpointURL: string | null; public interactionsEndpointURL: string | null;
public eventWebhooksURL: string | null;
public eventWebhooksStatus: ApplicationWebhookEventStatus | null;
public eventWebhooksTypes: ApplicationWebhookEventType[] | null;
public roleConnectionsVerificationURL: string | null; public roleConnectionsVerificationURL: string | null;
public rpcOrigins: string[]; public rpcOrigins: string[];
public edit(options: ClientApplicationEditOptions): Promise<ClientApplication>; public edit(options: ClientApplicationEditOptions): Promise<ClientApplication>;
@@ -7216,6 +7221,9 @@ export interface ClientApplicationEditOptions {
icon?: BufferResolvable | Base64Resolvable | null; icon?: BufferResolvable | Base64Resolvable | null;
coverImage?: BufferResolvable | Base64Resolvable | null; coverImage?: BufferResolvable | Base64Resolvable | null;
interactionsEndpointURL?: string; interactionsEndpointURL?: string;
eventWebhooksURL?: string;
eventWebhooksStatus?: ApplicationWebhookEventStatus.Enabled | ApplicationWebhookEventStatus.Disabled;
eventWebhooksTypes?: readonly ApplicationWebhookEventType[];
tags?: readonly string[]; tags?: readonly string[];
} }