diff --git a/deno/payloads/v10/application.ts b/deno/payloads/v10/application.ts index 8dfc67517..ea373b28e 100644 --- a/deno/payloads/v10/application.ts +++ b/deno/payloads/v10/application.ts @@ -9,6 +9,7 @@ import type { ApplicationIntegrationType } from './interactions.ts'; import type { OAuth2Scopes } from './oauth2.ts'; import type { APITeam } from './teams.ts'; import type { APIUser } from './user.ts'; +import type { ApplicationWebhookEventType } from './webhook.ts'; /** * https://discord.com/developers/docs/resources/application#application-object @@ -142,6 +143,18 @@ export interface APIApplication { * The application's default custom authorization link, if enabled */ custom_install_url?: string; + /** + * Event webhook URL for the app to receive webhook events + */ + event_webhooks_url?: string | null; + /** + * If webhook events are enabled for the app + */ + event_webhooks_status: ApplicationWebhookEventStatus; + /** + * List of webhook event types the app subscribes to + */ + event_webhooks_types?: ApplicationWebhookEventType[]; } export interface APIApplicationInstallParams { @@ -297,3 +310,21 @@ export enum ApplicationRoleConnectionMetadataType { */ BooleanNotEqual, } + +/** + * https://discord.com/developers/docs/resources/application#application-object-application-event-webhook-status + */ +export enum ApplicationWebhookEventStatus { + /** + * Webhook events are disabled by developer + */ + Disabled = 1, + /** + * Webhook events are enabled by developer + */ + Enabled, + /** + * Webhook events are disabled by Discord, usually due to inactivity + */ + DisabledByDiscord, +} diff --git a/deno/payloads/v10/webhook.ts b/deno/payloads/v10/webhook.ts index 7062a47ce..a2e104ae5 100644 --- a/deno/payloads/v10/webhook.ts +++ b/deno/payloads/v10/webhook.ts @@ -3,7 +3,15 @@ */ import type { Snowflake } from '../../globals.ts'; -import type { APIPartialChannel, APIPartialGuild, APIUser } from './mod.ts'; +import type { + APIEntitlement, + APIGuild, + APIPartialChannel, + APIPartialGuild, + APIUser, + ApplicationIntegrationType, + OAuth2Scopes, +} from './mod.ts'; /** * https://discord.com/developers/docs/resources/webhook#webhook-object @@ -63,6 +71,116 @@ export interface APIWebhook { url?: string; } +/** + * https://discord.com/developers/docs/events/webhook-events#webhook-event-payloads + */ +export type APIWebhookEvent = + | APIWebhookEventBase + | APIWebhookEventBase; + +/** + * https://discord.com/developers/docs/events/webhook-events#event-body-object + */ +export type APIWebhookEventBody = + | APIWebhookEventEventBase< + ApplicationWebhookEventType.ApplicationAuthorized, + APIWebhookEventApplicationAuthorizedData + > + | APIWebhookEventEventBase + | APIWebhookEventEventBase; + +export interface APIWebhookEventApplicationAuthorizedData { + /** + * Installation context for the authorization. Either guild (`0`) if installed to a server or user (`1`) if installed to a user's account + */ + integration_type?: ApplicationIntegrationType; + /** + * User who authorized the app + */ + user: APIUser; + /** + * List of scopes the user authorized + */ + scopes: OAuth2Scopes[]; + /** + * Server which app was authorized for (when integration type is `0`) + */ + guild?: APIGuild; +} + +export type APIWebhookEventEntitlementCreateData = APIEntitlement; + +export type APIWebhookEventQuestUserEnrollmentData = never; + +interface APIWebhookEventBase { + /** + * Version scheme for the webhook event. Currently always `1` + */ + version: 1; + /** + * ID of your app + */ + application_id: Snowflake; + /** + * Type of webhook + */ + type: Type; + /** + * Event data payload + */ + event: Event; +} + +/** + * https://discord.com/developers/docs/events/webhook-events#webhook-types + */ +export enum ApplicationWebhookType { + /** + * PING event sent to verify your Webhook Event URL is active + */ + Ping, + /** + * Webhook event (details for event in event body object) + */ + Event, +} + +interface APIWebhookEventEventBase { + /** + * Event type + */ + type: Type; + /** + * Timestamp of when the event occurred in ISO8601 format + */ + timestamp: string; + /** + * Data for the event. The shape depends on the event type + */ + data: Data; +} + +/** + * https://discord.com/developers/docs/events/webhook-events#event-types + */ +export enum ApplicationWebhookEventType { + /** + * Sent when an app was authorized by a user to a server or their account + */ + ApplicationAuthorized = 'APPLICATION_AUTHORIZED', + /** + * Entitlement was created + */ + EntitlementCreate = 'ENTITLEMENT_CREATE', + /** + * User was added to a Quest (currently unavailable) + */ + QuestUserEnrollment = 'QUEST_USER_ENROLLMENT', +} + +/** + * https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types + */ export enum WebhookType { /** * Incoming Webhooks can post messages to channels with a generated token diff --git a/deno/payloads/v9/application.ts b/deno/payloads/v9/application.ts index 8dfc67517..ea373b28e 100644 --- a/deno/payloads/v9/application.ts +++ b/deno/payloads/v9/application.ts @@ -9,6 +9,7 @@ import type { ApplicationIntegrationType } from './interactions.ts'; import type { OAuth2Scopes } from './oauth2.ts'; import type { APITeam } from './teams.ts'; import type { APIUser } from './user.ts'; +import type { ApplicationWebhookEventType } from './webhook.ts'; /** * https://discord.com/developers/docs/resources/application#application-object @@ -142,6 +143,18 @@ export interface APIApplication { * The application's default custom authorization link, if enabled */ custom_install_url?: string; + /** + * Event webhook URL for the app to receive webhook events + */ + event_webhooks_url?: string | null; + /** + * If webhook events are enabled for the app + */ + event_webhooks_status: ApplicationWebhookEventStatus; + /** + * List of webhook event types the app subscribes to + */ + event_webhooks_types?: ApplicationWebhookEventType[]; } export interface APIApplicationInstallParams { @@ -297,3 +310,21 @@ export enum ApplicationRoleConnectionMetadataType { */ BooleanNotEqual, } + +/** + * https://discord.com/developers/docs/resources/application#application-object-application-event-webhook-status + */ +export enum ApplicationWebhookEventStatus { + /** + * Webhook events are disabled by developer + */ + Disabled = 1, + /** + * Webhook events are enabled by developer + */ + Enabled, + /** + * Webhook events are disabled by Discord, usually due to inactivity + */ + DisabledByDiscord, +} diff --git a/deno/payloads/v9/webhook.ts b/deno/payloads/v9/webhook.ts index 7062a47ce..a2e104ae5 100644 --- a/deno/payloads/v9/webhook.ts +++ b/deno/payloads/v9/webhook.ts @@ -3,7 +3,15 @@ */ import type { Snowflake } from '../../globals.ts'; -import type { APIPartialChannel, APIPartialGuild, APIUser } from './mod.ts'; +import type { + APIEntitlement, + APIGuild, + APIPartialChannel, + APIPartialGuild, + APIUser, + ApplicationIntegrationType, + OAuth2Scopes, +} from './mod.ts'; /** * https://discord.com/developers/docs/resources/webhook#webhook-object @@ -63,6 +71,116 @@ export interface APIWebhook { url?: string; } +/** + * https://discord.com/developers/docs/events/webhook-events#webhook-event-payloads + */ +export type APIWebhookEvent = + | APIWebhookEventBase + | APIWebhookEventBase; + +/** + * https://discord.com/developers/docs/events/webhook-events#event-body-object + */ +export type APIWebhookEventBody = + | APIWebhookEventEventBase< + ApplicationWebhookEventType.ApplicationAuthorized, + APIWebhookEventApplicationAuthorizedData + > + | APIWebhookEventEventBase + | APIWebhookEventEventBase; + +export interface APIWebhookEventApplicationAuthorizedData { + /** + * Installation context for the authorization. Either guild (`0`) if installed to a server or user (`1`) if installed to a user's account + */ + integration_type?: ApplicationIntegrationType; + /** + * User who authorized the app + */ + user: APIUser; + /** + * List of scopes the user authorized + */ + scopes: OAuth2Scopes[]; + /** + * Server which app was authorized for (when integration type is `0`) + */ + guild?: APIGuild; +} + +export type APIWebhookEventEntitlementCreateData = APIEntitlement; + +export type APIWebhookEventQuestUserEnrollmentData = never; + +interface APIWebhookEventBase { + /** + * Version scheme for the webhook event. Currently always `1` + */ + version: 1; + /** + * ID of your app + */ + application_id: Snowflake; + /** + * Type of webhook + */ + type: Type; + /** + * Event data payload + */ + event: Event; +} + +/** + * https://discord.com/developers/docs/events/webhook-events#webhook-types + */ +export enum ApplicationWebhookType { + /** + * PING event sent to verify your Webhook Event URL is active + */ + Ping, + /** + * Webhook event (details for event in event body object) + */ + Event, +} + +interface APIWebhookEventEventBase { + /** + * Event type + */ + type: Type; + /** + * Timestamp of when the event occurred in ISO8601 format + */ + timestamp: string; + /** + * Data for the event. The shape depends on the event type + */ + data: Data; +} + +/** + * https://discord.com/developers/docs/events/webhook-events#event-types + */ +export enum ApplicationWebhookEventType { + /** + * Sent when an app was authorized by a user to a server or their account + */ + ApplicationAuthorized = 'APPLICATION_AUTHORIZED', + /** + * Entitlement was created + */ + EntitlementCreate = 'ENTITLEMENT_CREATE', + /** + * User was added to a Quest (currently unavailable) + */ + QuestUserEnrollment = 'QUEST_USER_ENROLLMENT', +} + +/** + * https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types + */ export enum WebhookType { /** * Incoming Webhooks can post messages to channels with a generated token diff --git a/payloads/v10/application.ts b/payloads/v10/application.ts index d168dac3f..6089384aa 100644 --- a/payloads/v10/application.ts +++ b/payloads/v10/application.ts @@ -9,6 +9,7 @@ import type { ApplicationIntegrationType } from './interactions'; import type { OAuth2Scopes } from './oauth2'; import type { APITeam } from './teams'; import type { APIUser } from './user'; +import type { ApplicationWebhookEventType } from './webhook'; /** * https://discord.com/developers/docs/resources/application#application-object @@ -142,6 +143,18 @@ export interface APIApplication { * The application's default custom authorization link, if enabled */ custom_install_url?: string; + /** + * Event webhook URL for the app to receive webhook events + */ + event_webhooks_url?: string | null; + /** + * If webhook events are enabled for the app + */ + event_webhooks_status: ApplicationWebhookEventStatus; + /** + * List of webhook event types the app subscribes to + */ + event_webhooks_types?: ApplicationWebhookEventType[]; } export interface APIApplicationInstallParams { @@ -297,3 +310,21 @@ export enum ApplicationRoleConnectionMetadataType { */ BooleanNotEqual, } + +/** + * https://discord.com/developers/docs/resources/application#application-object-application-event-webhook-status + */ +export enum ApplicationWebhookEventStatus { + /** + * Webhook events are disabled by developer + */ + Disabled = 1, + /** + * Webhook events are enabled by developer + */ + Enabled, + /** + * Webhook events are disabled by Discord, usually due to inactivity + */ + DisabledByDiscord, +} diff --git a/payloads/v10/webhook.ts b/payloads/v10/webhook.ts index 4886b987a..98d95ca80 100644 --- a/payloads/v10/webhook.ts +++ b/payloads/v10/webhook.ts @@ -3,7 +3,15 @@ */ import type { Snowflake } from '../../globals'; -import type { APIPartialChannel, APIPartialGuild, APIUser } from './index'; +import type { + APIEntitlement, + APIGuild, + APIPartialChannel, + APIPartialGuild, + APIUser, + ApplicationIntegrationType, + OAuth2Scopes, +} from './index'; /** * https://discord.com/developers/docs/resources/webhook#webhook-object @@ -63,6 +71,116 @@ export interface APIWebhook { url?: string; } +/** + * https://discord.com/developers/docs/events/webhook-events#webhook-event-payloads + */ +export type APIWebhookEvent = + | APIWebhookEventBase + | APIWebhookEventBase; + +/** + * https://discord.com/developers/docs/events/webhook-events#event-body-object + */ +export type APIWebhookEventBody = + | APIWebhookEventEventBase< + ApplicationWebhookEventType.ApplicationAuthorized, + APIWebhookEventApplicationAuthorizedData + > + | APIWebhookEventEventBase + | APIWebhookEventEventBase; + +export interface APIWebhookEventApplicationAuthorizedData { + /** + * Installation context for the authorization. Either guild (`0`) if installed to a server or user (`1`) if installed to a user's account + */ + integration_type?: ApplicationIntegrationType; + /** + * User who authorized the app + */ + user: APIUser; + /** + * List of scopes the user authorized + */ + scopes: OAuth2Scopes[]; + /** + * Server which app was authorized for (when integration type is `0`) + */ + guild?: APIGuild; +} + +export type APIWebhookEventEntitlementCreateData = APIEntitlement; + +export type APIWebhookEventQuestUserEnrollmentData = never; + +interface APIWebhookEventBase { + /** + * Version scheme for the webhook event. Currently always `1` + */ + version: 1; + /** + * ID of your app + */ + application_id: Snowflake; + /** + * Type of webhook + */ + type: Type; + /** + * Event data payload + */ + event: Event; +} + +/** + * https://discord.com/developers/docs/events/webhook-events#webhook-types + */ +export enum ApplicationWebhookType { + /** + * PING event sent to verify your Webhook Event URL is active + */ + Ping, + /** + * Webhook event (details for event in event body object) + */ + Event, +} + +interface APIWebhookEventEventBase { + /** + * Event type + */ + type: Type; + /** + * Timestamp of when the event occurred in ISO8601 format + */ + timestamp: string; + /** + * Data for the event. The shape depends on the event type + */ + data: Data; +} + +/** + * https://discord.com/developers/docs/events/webhook-events#event-types + */ +export enum ApplicationWebhookEventType { + /** + * Sent when an app was authorized by a user to a server or their account + */ + ApplicationAuthorized = 'APPLICATION_AUTHORIZED', + /** + * Entitlement was created + */ + EntitlementCreate = 'ENTITLEMENT_CREATE', + /** + * User was added to a Quest (currently unavailable) + */ + QuestUserEnrollment = 'QUEST_USER_ENROLLMENT', +} + +/** + * https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types + */ export enum WebhookType { /** * Incoming Webhooks can post messages to channels with a generated token diff --git a/payloads/v9/application.ts b/payloads/v9/application.ts index d168dac3f..6089384aa 100644 --- a/payloads/v9/application.ts +++ b/payloads/v9/application.ts @@ -9,6 +9,7 @@ import type { ApplicationIntegrationType } from './interactions'; import type { OAuth2Scopes } from './oauth2'; import type { APITeam } from './teams'; import type { APIUser } from './user'; +import type { ApplicationWebhookEventType } from './webhook'; /** * https://discord.com/developers/docs/resources/application#application-object @@ -142,6 +143,18 @@ export interface APIApplication { * The application's default custom authorization link, if enabled */ custom_install_url?: string; + /** + * Event webhook URL for the app to receive webhook events + */ + event_webhooks_url?: string | null; + /** + * If webhook events are enabled for the app + */ + event_webhooks_status: ApplicationWebhookEventStatus; + /** + * List of webhook event types the app subscribes to + */ + event_webhooks_types?: ApplicationWebhookEventType[]; } export interface APIApplicationInstallParams { @@ -297,3 +310,21 @@ export enum ApplicationRoleConnectionMetadataType { */ BooleanNotEqual, } + +/** + * https://discord.com/developers/docs/resources/application#application-object-application-event-webhook-status + */ +export enum ApplicationWebhookEventStatus { + /** + * Webhook events are disabled by developer + */ + Disabled = 1, + /** + * Webhook events are enabled by developer + */ + Enabled, + /** + * Webhook events are disabled by Discord, usually due to inactivity + */ + DisabledByDiscord, +} diff --git a/payloads/v9/webhook.ts b/payloads/v9/webhook.ts index 4886b987a..98d95ca80 100644 --- a/payloads/v9/webhook.ts +++ b/payloads/v9/webhook.ts @@ -3,7 +3,15 @@ */ import type { Snowflake } from '../../globals'; -import type { APIPartialChannel, APIPartialGuild, APIUser } from './index'; +import type { + APIEntitlement, + APIGuild, + APIPartialChannel, + APIPartialGuild, + APIUser, + ApplicationIntegrationType, + OAuth2Scopes, +} from './index'; /** * https://discord.com/developers/docs/resources/webhook#webhook-object @@ -63,6 +71,116 @@ export interface APIWebhook { url?: string; } +/** + * https://discord.com/developers/docs/events/webhook-events#webhook-event-payloads + */ +export type APIWebhookEvent = + | APIWebhookEventBase + | APIWebhookEventBase; + +/** + * https://discord.com/developers/docs/events/webhook-events#event-body-object + */ +export type APIWebhookEventBody = + | APIWebhookEventEventBase< + ApplicationWebhookEventType.ApplicationAuthorized, + APIWebhookEventApplicationAuthorizedData + > + | APIWebhookEventEventBase + | APIWebhookEventEventBase; + +export interface APIWebhookEventApplicationAuthorizedData { + /** + * Installation context for the authorization. Either guild (`0`) if installed to a server or user (`1`) if installed to a user's account + */ + integration_type?: ApplicationIntegrationType; + /** + * User who authorized the app + */ + user: APIUser; + /** + * List of scopes the user authorized + */ + scopes: OAuth2Scopes[]; + /** + * Server which app was authorized for (when integration type is `0`) + */ + guild?: APIGuild; +} + +export type APIWebhookEventEntitlementCreateData = APIEntitlement; + +export type APIWebhookEventQuestUserEnrollmentData = never; + +interface APIWebhookEventBase { + /** + * Version scheme for the webhook event. Currently always `1` + */ + version: 1; + /** + * ID of your app + */ + application_id: Snowflake; + /** + * Type of webhook + */ + type: Type; + /** + * Event data payload + */ + event: Event; +} + +/** + * https://discord.com/developers/docs/events/webhook-events#webhook-types + */ +export enum ApplicationWebhookType { + /** + * PING event sent to verify your Webhook Event URL is active + */ + Ping, + /** + * Webhook event (details for event in event body object) + */ + Event, +} + +interface APIWebhookEventEventBase { + /** + * Event type + */ + type: Type; + /** + * Timestamp of when the event occurred in ISO8601 format + */ + timestamp: string; + /** + * Data for the event. The shape depends on the event type + */ + data: Data; +} + +/** + * https://discord.com/developers/docs/events/webhook-events#event-types + */ +export enum ApplicationWebhookEventType { + /** + * Sent when an app was authorized by a user to a server or their account + */ + ApplicationAuthorized = 'APPLICATION_AUTHORIZED', + /** + * Entitlement was created + */ + EntitlementCreate = 'ENTITLEMENT_CREATE', + /** + * User was added to a Quest (currently unavailable) + */ + QuestUserEnrollment = 'QUEST_USER_ENROLLMENT', +} + +/** + * https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types + */ export enum WebhookType { /** * Incoming Webhooks can post messages to channels with a generated token