fix(APIInteraction): add modal submit interaction & make data required in APIModalSubmit (#321)

This commit is contained in:
Almeida
2022-02-11 18:25:27 +00:00
committed by GitHub
parent 72e9617fee
commit f88727bd80
9 changed files with 141 additions and 20 deletions

View File

@@ -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<InteractionType.ModalSubmit, APIModalSubmission>;
export type APIModalSubmitInteraction = APIBaseInteraction<InteractionType.ModalSubmit, APIModalSubmission> &
Required<Pick<APIBaseInteraction<InteractionType.ModalSubmit, APIModalSubmission>, 'data'>>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIModalSubmitDMInteraction = APIDMInteractionWrapper<APIModalSubmitInteraction>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIModalSubmitGuildInteraction = APIGuildInteractionWrapper<APIModalSubmitInteraction>;

View File

@@ -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;

View File

@@ -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<InteractionType.ModalSubmit, APIModalSubmission>;
export type APIModalSubmitInteraction = APIBaseInteraction<InteractionType.ModalSubmit, APIModalSubmission> &
Required<Pick<APIBaseInteraction<InteractionType.ModalSubmit, APIModalSubmission>, 'data'>>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIModalSubmitDMInteraction = APIDMInteractionWrapper<APIModalSubmitInteraction>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIModalSubmitGuildInteraction = APIGuildInteractionWrapper<APIModalSubmitInteraction>;

View File

@@ -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;

View File

@@ -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<InteractionType.ModalSubmit, APIModalSubmission>;
export type APIModalSubmitInteraction = APIBaseInteraction<InteractionType.ModalSubmit, APIModalSubmission> &
Required<Pick<APIBaseInteraction<InteractionType.ModalSubmit, APIModalSubmission>, 'data'>>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIModalSubmitDMInteraction = APIDMInteractionWrapper<APIModalSubmitInteraction>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIModalSubmitGuildInteraction = APIGuildInteractionWrapper<APIModalSubmitInteraction>;

View File

@@ -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;

View File

@@ -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<InteractionType.ModalSubmit, APIModalSubmission>;
export type APIModalSubmitInteraction = APIBaseInteraction<InteractionType.ModalSubmit, APIModalSubmission> &
Required<Pick<APIBaseInteraction<InteractionType.ModalSubmit, APIModalSubmission>, 'data'>>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIModalSubmitDMInteraction = APIDMInteractionWrapper<APIModalSubmitInteraction>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIModalSubmitGuildInteraction = APIGuildInteractionWrapper<APIModalSubmitInteraction>;

View File

@@ -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;

View File

@@ -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<APIModalSubmission>(interaction.data);
}
declare const dmInteraction: APIDMInteraction;
expectType<APIUser>(dmInteraction.user);