Skip to content

Commit ae1deac

Browse files
imnaiyarJiralitealmeidx
committed
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 <[email protected]> Co-authored-by: Almeida <[email protected]>
1 parent a367e2c commit ae1deac

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

packages/discord.js/src/structures/ClientApplication.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,36 @@ class ClientApplication extends Application {
243243
this.roleConnectionsVerificationURL ??= null;
244244
}
245245

246+
if ('event_webhooks_url' in data) {
247+
/**
248+
* This application's URL to receive event webhooks
249+
* @type {?string}
250+
*/
251+
this.eventWebhooksURL = data.event_webhooks_url;
252+
} else {
253+
this.eventWebhooksURL ??= null;
254+
}
255+
256+
if ('event_webhooks_status' in data) {
257+
/**
258+
* This application's event webhooks status
259+
* @type {?ApplicationWebhookEventStatus}
260+
*/
261+
this.eventWebhooksStatus = data.event_webhooks_status;
262+
} else {
263+
this.eventWebhooksStatus ??= null;
264+
}
265+
266+
if ('event_webhooks_types' in data) {
267+
/**
268+
* List of event webhooks types this application subscribes to
269+
* @type {?ApplicationWebhookEventType[]}
270+
*/
271+
this.eventWebhooksTypes = data.event_webhooks_types;
272+
} else {
273+
this.eventWebhooksTypes ??= null;
274+
}
275+
246276
/**
247277
* The owner of this OAuth application
248278
* @type {?(User|Team)}
@@ -284,6 +314,10 @@ class ClientApplication extends Application {
284314
* @property {?(BufferResolvable|Base64Resolvable)} [icon] The application's icon
285315
* @property {?(BufferResolvable|Base64Resolvable)} [coverImage] The application's cover image
286316
* @property {string} [interactionsEndpointURL] The application's interaction endpoint URL
317+
* @property {string} [eventWebhooksURL] The application's event webhooks URL
318+
* @property {ApplicationWebhookEventStatus.Enabled|ApplicationWebhookEventStatus.Disabled} [eventWebhooksStatus]
319+
* The application's event webhooks status.
320+
* @property {ApplicationWebhookEventType[]} [eventWebhooksTypes] The application's event webhooks types
287321
* @property {string[]} [tags] The application's tags
288322
*/
289323

@@ -301,6 +335,9 @@ class ClientApplication extends Application {
301335
icon,
302336
coverImage,
303337
interactionsEndpointURL,
338+
eventWebhooksURL,
339+
eventWebhooksStatus,
340+
eventWebhooksTypes,
304341
tags,
305342
} = {}) {
306343
const data = await this.client.rest.patch(Routes.currentApplication(), {
@@ -313,6 +350,9 @@ class ClientApplication extends Application {
313350
icon: icon && (await resolveImage(icon)),
314351
cover_image: coverImage && (await resolveImage(coverImage)),
315352
interactions_endpoint_url: interactionsEndpointURL,
353+
event_webhooks_url: eventWebhooksURL,
354+
event_webhooks_status: eventWebhooksStatus,
355+
event_webhooks_types: eventWebhooksTypes,
316356
tags,
317357
},
318358
});

packages/discord.js/src/util/APITypes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,16 @@
255255
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationRoleConnectionMetadataType}
256256
*/
257257

258+
/**
259+
* @external ApplicationWebhookEventStatus
260+
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationWebhookEventStatus}
261+
*/
262+
263+
/**
264+
* @external ApplicationWebhookEventType
265+
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationWebhookEventType}
266+
*/
267+
258268
/**
259269
* @external AttachmentFlags
260270
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/AttachmentFlags}

packages/discord.js/typings/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ import {
191191
GuildScheduledEventRecurrenceRuleFrequency,
192192
APISubscription,
193193
SubscriptionStatus,
194+
ApplicationWebhookEventStatus,
195+
ApplicationWebhookEventType,
194196
VoiceChannelEffectSendAnimationType,
195197
GatewayVoiceChannelEffectSendDispatchData,
196198
} from 'discord-api-types/v10';
@@ -1097,6 +1099,9 @@ export class ClientApplication extends Application {
10971099
public owner: User | Team | null;
10981100
public get partial(): boolean;
10991101
public interactionsEndpointURL: string | null;
1102+
public eventWebhooksURL: string | null;
1103+
public eventWebhooksStatus: ApplicationWebhookEventStatus | null;
1104+
public eventWebhooksTypes: ApplicationWebhookEventType[] | null;
11001105
public roleConnectionsVerificationURL: string | null;
11011106
public rpcOrigins: string[];
11021107
public edit(options: ClientApplicationEditOptions): Promise<ClientApplication>;
@@ -7216,6 +7221,9 @@ export interface ClientApplicationEditOptions {
72167221
icon?: BufferResolvable | Base64Resolvable | null;
72177222
coverImage?: BufferResolvable | Base64Resolvable | null;
72187223
interactionsEndpointURL?: string;
7224+
eventWebhooksURL?: string;
7225+
eventWebhooksStatus?: ApplicationWebhookEventStatus.Enabled | ApplicationWebhookEventStatus.Disabled;
7226+
eventWebhooksTypes?: readonly ApplicationWebhookEventType[];
72197227
tags?: readonly string[];
72207228
}
72217229

0 commit comments

Comments
 (0)