Skip to content

Commit

Permalink
feat(ClientApplication): add webhook events
Browse files Browse the repository at this point in the history
  • Loading branch information
imnaiyar committed Nov 21, 2024
1 parent 98153ba commit 8a3f0da
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
39 changes: 39 additions & 0 deletions packages/discord.js/src/structures/ClientApplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down Expand Up @@ -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
*/

Expand All @@ -294,6 +327,9 @@ class ClientApplication extends Application {
icon,
coverImage,
interactionsEndpointURL,
eventWebhooksURL,
eventWebhooksStatus,
eventWebhooksTypes,
tags,
} = {}) {
const data = await this.client.rest.patch(Routes.currentApplication(), {
Expand All @@ -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,
},
});
Expand Down
8 changes: 8 additions & 0 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ import {
GuildScheduledEventRecurrenceRuleFrequency,
GatewaySendPayload,
GatewayDispatchPayload,
ApplicationEventWebhookStatus,
WebhookEventType,
VoiceChannelEffectSendAnimationType,
GatewayVoiceChannelEffectSendDispatchData,
} from 'discord-api-types/v10';
Expand Down Expand Up @@ -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<ClientApplication>;
Expand Down Expand Up @@ -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[];
}

Expand Down

0 comments on commit 8a3f0da

Please sign in to comment.