From f88727bd80d32f3ddf4374b1fd46ce50c36eea4d Mon Sep 17 00:00:00 2001 From: Almeida Date: Fri, 11 Feb 2022 18:25:27 +0000 Subject: [PATCH] fix(APIInteraction): add modal submit interaction & make `data` required in APIModalSubmit (#321) --- deno/payloads/v8/_interactions/modalSubmit.ts | 21 +++++++++++++++++-- deno/payloads/v8/interactions.ts | 18 +++++++++++++--- deno/payloads/v9/_interactions/modalSubmit.ts | 21 +++++++++++++++++-- deno/payloads/v9/interactions.ts | 18 +++++++++++++--- payloads/v8/_interactions/modalSubmit.ts | 21 +++++++++++++++++-- payloads/v8/interactions.ts | 18 +++++++++++++--- payloads/v9/_interactions/modalSubmit.ts | 21 +++++++++++++++++-- payloads/v9/interactions.ts | 18 +++++++++++++--- tests/v9/interactions.test-d.ts | 5 +++++ 9 files changed, 141 insertions(+), 20 deletions(-) diff --git a/deno/payloads/v8/_interactions/modalSubmit.ts b/deno/payloads/v8/_interactions/modalSubmit.ts index c092492cf..b8537f2f4 100644 --- a/deno/payloads/v8/_interactions/modalSubmit.ts +++ b/deno/payloads/v8/_interactions/modalSubmit.ts @@ -1,5 +1,11 @@ import type { APIActionRowComponent, APIModalComponent } from '../channel.ts'; -import type { APIBaseInteraction, InteractionType, ComponentType } from '../mod.ts'; +import type { + APIBaseInteraction, + InteractionType, + ComponentType, + APIDMInteractionWrapper, + APIGuildInteractionWrapper, +} from '../mod.ts'; export interface ModalSubmitComponent { type: ComponentType; @@ -25,4 +31,15 @@ export interface APIModalSubmission { /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export type APIModalSubmitInteraction = APIBaseInteraction; +export type APIModalSubmitInteraction = APIBaseInteraction & + Required, 'data'>>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitDMInteraction = APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitGuildInteraction = APIGuildInteractionWrapper; diff --git a/deno/payloads/v8/interactions.ts b/deno/payloads/v8/interactions.ts index 68256d1c9..25b028838 100644 --- a/deno/payloads/v8/interactions.ts +++ b/deno/payloads/v8/interactions.ts @@ -10,6 +10,11 @@ import type { APIApplicationCommandInteraction, } from './_interactions/applicationCommands.ts'; import type { APIApplicationCommandAutocompleteInteraction } from './_interactions/autocomplete.ts'; +import type { + APIModalSubmitDMInteraction, + APIModalSubmitGuildInteraction, + APIModalSubmitInteraction, +} from './_interactions/modalSubmit.ts'; export * from './_interactions/base.ts'; export * from './_interactions/messageComponents.ts'; @@ -25,14 +30,21 @@ export type APIInteraction = | APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction - | APIApplicationCommandAutocompleteInteraction; + | APIApplicationCommandAutocompleteInteraction + | APIModalSubmitInteraction; /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction; +export type APIDMInteraction = + | APIApplicationCommandDMInteraction + | APIMessageComponentDMInteraction + | APIModalSubmitDMInteraction; /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction; +export type APIGuildInteraction = + | APIApplicationCommandGuildInteraction + | APIMessageComponentGuildInteraction + | APIModalSubmitGuildInteraction; diff --git a/deno/payloads/v9/_interactions/modalSubmit.ts b/deno/payloads/v9/_interactions/modalSubmit.ts index c092492cf..b8537f2f4 100644 --- a/deno/payloads/v9/_interactions/modalSubmit.ts +++ b/deno/payloads/v9/_interactions/modalSubmit.ts @@ -1,5 +1,11 @@ import type { APIActionRowComponent, APIModalComponent } from '../channel.ts'; -import type { APIBaseInteraction, InteractionType, ComponentType } from '../mod.ts'; +import type { + APIBaseInteraction, + InteractionType, + ComponentType, + APIDMInteractionWrapper, + APIGuildInteractionWrapper, +} from '../mod.ts'; export interface ModalSubmitComponent { type: ComponentType; @@ -25,4 +31,15 @@ export interface APIModalSubmission { /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export type APIModalSubmitInteraction = APIBaseInteraction; +export type APIModalSubmitInteraction = APIBaseInteraction & + Required, 'data'>>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitDMInteraction = APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitGuildInteraction = APIGuildInteractionWrapper; diff --git a/deno/payloads/v9/interactions.ts b/deno/payloads/v9/interactions.ts index 68256d1c9..25b028838 100644 --- a/deno/payloads/v9/interactions.ts +++ b/deno/payloads/v9/interactions.ts @@ -10,6 +10,11 @@ import type { APIApplicationCommandInteraction, } from './_interactions/applicationCommands.ts'; import type { APIApplicationCommandAutocompleteInteraction } from './_interactions/autocomplete.ts'; +import type { + APIModalSubmitDMInteraction, + APIModalSubmitGuildInteraction, + APIModalSubmitInteraction, +} from './_interactions/modalSubmit.ts'; export * from './_interactions/base.ts'; export * from './_interactions/messageComponents.ts'; @@ -25,14 +30,21 @@ export type APIInteraction = | APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction - | APIApplicationCommandAutocompleteInteraction; + | APIApplicationCommandAutocompleteInteraction + | APIModalSubmitInteraction; /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction; +export type APIDMInteraction = + | APIApplicationCommandDMInteraction + | APIMessageComponentDMInteraction + | APIModalSubmitDMInteraction; /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction; +export type APIGuildInteraction = + | APIApplicationCommandGuildInteraction + | APIMessageComponentGuildInteraction + | APIModalSubmitGuildInteraction; diff --git a/payloads/v8/_interactions/modalSubmit.ts b/payloads/v8/_interactions/modalSubmit.ts index 9f429044a..394c0a0ee 100644 --- a/payloads/v8/_interactions/modalSubmit.ts +++ b/payloads/v8/_interactions/modalSubmit.ts @@ -1,5 +1,11 @@ import type { APIActionRowComponent, APIModalComponent } from '../channel'; -import type { APIBaseInteraction, InteractionType, ComponentType } from '../index'; +import type { + APIBaseInteraction, + InteractionType, + ComponentType, + APIDMInteractionWrapper, + APIGuildInteractionWrapper, +} from '../index'; export interface ModalSubmitComponent { type: ComponentType; @@ -25,4 +31,15 @@ export interface APIModalSubmission { /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export type APIModalSubmitInteraction = APIBaseInteraction; +export type APIModalSubmitInteraction = APIBaseInteraction & + Required, 'data'>>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitDMInteraction = APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitGuildInteraction = APIGuildInteractionWrapper; diff --git a/payloads/v8/interactions.ts b/payloads/v8/interactions.ts index 5448a203e..4951d2441 100644 --- a/payloads/v8/interactions.ts +++ b/payloads/v8/interactions.ts @@ -10,6 +10,11 @@ import type { APIApplicationCommandInteraction, } from './_interactions/applicationCommands'; import type { APIApplicationCommandAutocompleteInteraction } from './_interactions/autocomplete'; +import type { + APIModalSubmitDMInteraction, + APIModalSubmitGuildInteraction, + APIModalSubmitInteraction, +} from './_interactions/modalSubmit'; export * from './_interactions/base'; export * from './_interactions/messageComponents'; @@ -25,14 +30,21 @@ export type APIInteraction = | APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction - | APIApplicationCommandAutocompleteInteraction; + | APIApplicationCommandAutocompleteInteraction + | APIModalSubmitInteraction; /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction; +export type APIDMInteraction = + | APIApplicationCommandDMInteraction + | APIMessageComponentDMInteraction + | APIModalSubmitDMInteraction; /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction; +export type APIGuildInteraction = + | APIApplicationCommandGuildInteraction + | APIMessageComponentGuildInteraction + | APIModalSubmitGuildInteraction; diff --git a/payloads/v9/_interactions/modalSubmit.ts b/payloads/v9/_interactions/modalSubmit.ts index 9f429044a..394c0a0ee 100644 --- a/payloads/v9/_interactions/modalSubmit.ts +++ b/payloads/v9/_interactions/modalSubmit.ts @@ -1,5 +1,11 @@ import type { APIActionRowComponent, APIModalComponent } from '../channel'; -import type { APIBaseInteraction, InteractionType, ComponentType } from '../index'; +import type { + APIBaseInteraction, + InteractionType, + ComponentType, + APIDMInteractionWrapper, + APIGuildInteractionWrapper, +} from '../index'; export interface ModalSubmitComponent { type: ComponentType; @@ -25,4 +31,15 @@ export interface APIModalSubmission { /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export type APIModalSubmitInteraction = APIBaseInteraction; +export type APIModalSubmitInteraction = APIBaseInteraction & + Required, 'data'>>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitDMInteraction = APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIModalSubmitGuildInteraction = APIGuildInteractionWrapper; diff --git a/payloads/v9/interactions.ts b/payloads/v9/interactions.ts index 5448a203e..4951d2441 100644 --- a/payloads/v9/interactions.ts +++ b/payloads/v9/interactions.ts @@ -10,6 +10,11 @@ import type { APIApplicationCommandInteraction, } from './_interactions/applicationCommands'; import type { APIApplicationCommandAutocompleteInteraction } from './_interactions/autocomplete'; +import type { + APIModalSubmitDMInteraction, + APIModalSubmitGuildInteraction, + APIModalSubmitInteraction, +} from './_interactions/modalSubmit'; export * from './_interactions/base'; export * from './_interactions/messageComponents'; @@ -25,14 +30,21 @@ export type APIInteraction = | APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction - | APIApplicationCommandAutocompleteInteraction; + | APIApplicationCommandAutocompleteInteraction + | APIModalSubmitInteraction; /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction; +export type APIDMInteraction = + | APIApplicationCommandDMInteraction + | APIMessageComponentDMInteraction + | APIModalSubmitDMInteraction; /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction; +export type APIGuildInteraction = + | APIApplicationCommandGuildInteraction + | APIMessageComponentGuildInteraction + | APIModalSubmitGuildInteraction; diff --git a/tests/v9/interactions.test-d.ts b/tests/v9/interactions.test-d.ts index 5a0e76437..bdb14484f 100644 --- a/tests/v9/interactions.test-d.ts +++ b/tests/v9/interactions.test-d.ts @@ -7,6 +7,7 @@ import { APIInteraction, APIInteractionGuildMember, APIMessageComponentInteraction, + APIModalSubmission, APIUser, ComponentType, InteractionType, @@ -37,6 +38,10 @@ if (interaction.type === InteractionType.MessageComponent) { } } +if (interaction.type === InteractionType.ModalSubmit) { + expectType(interaction.data); +} + declare const dmInteraction: APIDMInteraction; expectType(dmInteraction.user);