Skip to content

Commit

Permalink
types(showModal): align types with the documentation (#7600)
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidx committed Mar 6, 2022
1 parent fac55bc commit 0d7e4ed
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export interface InteractionResponseFields<Cached extends CacheType = CacheType>
deferReply(options?: InteractionDeferReplyOptions): Promise<void>;
fetchReply(): Promise<GuildCacheMessage<Cached>>;
followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<GuildCacheMessage<Cached>>;
showModal(modal: Modal): Promise<void>;
showModal(modal: Modal | ModalData | APIModalInteractionResponseCallbackData): Promise<void>;
}

export abstract class CommandInteraction<Cached extends CacheType = CacheType> extends Interaction<Cached> {
Expand Down Expand Up @@ -391,7 +391,7 @@ export abstract class CommandInteraction<Cached extends CacheType = CacheType> e
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<GuildCacheMessage<Cached>>;
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<GuildCacheMessage<Cached>>;
public reply(options: string | MessagePayload | InteractionReplyOptions): Promise<void>;
public showModal(modal: Modal): Promise<void>;
public showModal(modal: Modal | ModalData | APIModalInteractionResponseCallbackData): Promise<void>;
private transformOption(
option: APIApplicationCommandOption,
resolved: APIApplicationCommandInteractionData['resolved'],
Expand Down Expand Up @@ -1647,7 +1647,7 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
public reply(options: string | MessagePayload | InteractionReplyOptions): Promise<void>;
public update(options: InteractionUpdateOptions & { fetchReply: true }): Promise<GuildCacheMessage<Cached>>;
public update(options: string | MessagePayload | InteractionUpdateOptions): Promise<void>;
public showModal(modal: Modal): Promise<void>;
public showModal(modal: Modal | ModalData | APIModalInteractionResponseCallbackData): Promise<void>;
}

export class MessageContextMenuCommandInteraction<
Expand Down
24 changes: 24 additions & 0 deletions packages/discord.js/typings/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
PermissionFlagsBits,
AuditLogEvent,
ButtonStyle,
TextInputStyle,
} from 'discord-api-types/v9';
import {
ApplicationCommand,
Expand Down Expand Up @@ -58,6 +59,7 @@ import {
MessageCollector,
MessageComponentInteraction,
MessageReaction,
Modal,
NewsChannel,
Options,
PartialTextBasedChannelFields,
Expand Down Expand Up @@ -1353,3 +1355,25 @@ declare const chatInputInteraction: ChatInputCommandInteraction;

expectType<MessageAttachment>(chatInputInteraction.options.getAttachment('attachment', true));
expectType<MessageAttachment | null>(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,
},
],
});

0 comments on commit 0d7e4ed

Please sign in to comment.