From 0d7e4edd969513692c061c107be4bbe7e4b54321 Mon Sep 17 00:00:00 2001 From: Almeida Date: Sun, 6 Mar 2022 15:25:56 +0000 Subject: [PATCH] types(showModal): align types with the documentation (#7600) --- packages/discord.js/typings/index.d.ts | 6 +++--- packages/discord.js/typings/index.test-d.ts | 24 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 1e2cd759f..82759b9e9 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -352,7 +352,7 @@ export interface InteractionResponseFields deferReply(options?: InteractionDeferReplyOptions): Promise; fetchReply(): Promise>; followUp(options: string | MessagePayload | InteractionReplyOptions): Promise>; - showModal(modal: Modal): Promise; + showModal(modal: Modal | ModalData | APIModalInteractionResponseCallbackData): Promise; } export abstract class CommandInteraction extends Interaction { @@ -391,7 +391,7 @@ export abstract class CommandInteraction e public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise>; public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise>; public reply(options: string | MessagePayload | InteractionReplyOptions): Promise; - public showModal(modal: Modal): Promise; + public showModal(modal: Modal | ModalData | APIModalInteractionResponseCallbackData): Promise; private transformOption( option: APIApplicationCommandOption, resolved: APIApplicationCommandInteractionData['resolved'], @@ -1647,7 +1647,7 @@ export class MessageComponentInteraction e public reply(options: string | MessagePayload | InteractionReplyOptions): Promise; public update(options: InteractionUpdateOptions & { fetchReply: true }): Promise>; public update(options: string | MessagePayload | InteractionUpdateOptions): Promise; - public showModal(modal: Modal): Promise; + public showModal(modal: Modal | ModalData | APIModalInteractionResponseCallbackData): Promise; } export class MessageContextMenuCommandInteraction< diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index ea4df20d7..d922e8724 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -19,6 +19,7 @@ import { PermissionFlagsBits, AuditLogEvent, ButtonStyle, + TextInputStyle, } from 'discord-api-types/v9'; import { ApplicationCommand, @@ -58,6 +59,7 @@ import { MessageCollector, MessageComponentInteraction, MessageReaction, + Modal, NewsChannel, Options, PartialTextBasedChannelFields, @@ -1353,3 +1355,25 @@ declare const chatInputInteraction: ChatInputCommandInteraction; expectType(chatInputInteraction.options.getAttachment('attachment', true)); expectType(chatInputInteraction.options.getAttachment('attachment')); + +declare const modal: Modal; + +chatInputInteraction.showModal(modal); + +chatInputInteraction.showModal({ + title: 'abc', + custom_id: 'abc', + components: [ + { + components: [ + { + custom_id: 'aa', + label: 'label', + style: TextInputStyle.Short, + type: ComponentType.TextInput, + }, + ], + type: ComponentType.ActionRow, + }, + ], +});