Skip to content

Commit 8e3fdfe

Browse files
committed
feat: support select in modals
1 parent 53f4710 commit 8e3fdfe

File tree

12 files changed

+158
-42
lines changed

12 files changed

+158
-42
lines changed

deno/payloads/v10/_interactions/modalSubmit.ts

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deno/payloads/v10/_interactions/responses.ts

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deno/payloads/v10/channel.ts

Lines changed: 40 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deno/payloads/v9/_interactions/modalSubmit.ts

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deno/payloads/v9/_interactions/responses.ts

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deno/payloads/v9/channel.ts

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

payloads/v10/_interactions/modalSubmit.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { APIBaseComponent } from '../channel';
1+
import type { APIBaseComponent, APILabelComponent } from '../channel';
22
import type {
33
APIBaseInteraction,
44
APIDMInteractionWrapper,
@@ -17,6 +17,10 @@ export interface ModalSubmitActionRowComponent extends APIBaseComponent<Componen
1717
components: ModalSubmitComponent[];
1818
}
1919

20+
export interface ModalSubmitLabelComponent extends APIBaseComponent<ComponentType.Label> {
21+
component: APILabelComponent;
22+
}
23+
2024
/**
2125
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-modal-submit-data-structure}
2226
*/
@@ -28,7 +32,7 @@ export interface APIModalSubmission {
2832
/**
2933
* A list of child components
3034
*/
31-
components: ModalSubmitActionRowComponent[];
35+
components: (ModalSubmitActionRowComponent | ModalSubmitLabelComponent)[];
3236
}
3337

3438
/**

payloads/v10/_interactions/responses.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v10';
2-
import type { APIActionRowComponent, APIComponentInModalActionRow } from '../channel';
2+
import type { APIActionRowComponent, APIComponentInModalActionRow, APILabelComponent } from '../channel';
33
import type { APIApplicationCommandOptionChoice } from './applicationCommands';
44

55
/**
@@ -140,6 +140,8 @@ export interface APIModalInteractionResponseCallbackData {
140140
title: string;
141141
/**
142142
* Between 1 and 5 (inclusive) components that make up the modal
143+
*
144+
* @remarks Using action rows inside modals is deprecated.
143145
*/
144-
components: APIActionRowComponent<APIComponentInModalActionRow>[];
146+
components: APIActionRowComponent<APIComponentInModalActionRow>[] | APILabelComponent;
145147
}

payloads/v10/channel.ts

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,10 @@ export enum ComponentType {
17051705
* Container that visually groups a set of components
17061706
*/
17071707
Container,
1708-
1708+
/**
1709+
* Labels for use in modals.
1710+
*/
1711+
Label,
17091712
// EVERYTHING BELOW THIS LINE SHOULD BE OLD NAMES FOR RENAMED ENUM MEMBERS //
17101713

17111714
/**
@@ -1717,7 +1720,7 @@ export enum ComponentType {
17171720
}
17181721

17191722
/**
1720-
* An Action Row is a top-level layout component used in messages and modals.
1723+
* An Action Row is a top-level layout component used in messages. Use in modals is deprecated.
17211724
*
17221725
* @see {@link https://discord.com/developers/docs/components/reference#action-row}
17231726
*/
@@ -1930,6 +1933,13 @@ export interface APIStringSelectComponent extends APIBaseSelectMenuComponent<Com
19301933
options: APISelectMenuOption[];
19311934
}
19321935

1936+
/**
1937+
* A string select menu component that may be used in modals.
1938+
*/
1939+
export interface APIStringSelectComponentInModal extends APIStringSelectComponent {
1940+
required?: boolean;
1941+
}
1942+
19331943
/**
19341944
* A User Select is an interactive component that allows users to select one or more users in a message. Options are automatically populated based on the server's available users.
19351945
*
@@ -2051,16 +2061,7 @@ export interface APISelectMenuOption {
20512061
default?: boolean;
20522062
}
20532063

2054-
/**
2055-
* Text Input is an interactive component that allows users to enter free-form text responses in modals. It supports both short, single-line inputs and longer, multi-line paragraph inputs.
2056-
*
2057-
* Text Inputs can only be used within modals and must be placed inside an Action Row.
2058-
*
2059-
* When defining a text input component, you can set attributes to customize the behavior and appearance of it. However, not all attributes will be returned in the text input interaction payload.
2060-
*
2061-
* @see {@link https://discord.com/developers/docs/components/reference#text-input}
2062-
*/
2063-
export interface APITextInputComponent extends APIBaseComponent<ComponentType.TextInput> {
2064+
export interface APIBaseTextInputComponent extends APIBaseComponent<ComponentType.TextInput> {
20642065
/**
20652066
* One of text input styles
20662067
*/
@@ -2095,6 +2096,27 @@ export interface APITextInputComponent extends APIBaseComponent<ComponentType.Te
20952096
required?: boolean;
20962097
}
20972098

2099+
/**
2100+
* Text Input is an interactive component that allows users to enter free-form text responses in modals. It supports both short, single-line inputs and longer, multi-line paragraph inputs.
2101+
*
2102+
* Text Inputs can only be used within modals and must be placed inside an Action Row.
2103+
*
2104+
* When defining a text input component, you can set attributes to customize the behavior and appearance of it. However, not all attributes will be returned in the text input interaction payload.
2105+
*
2106+
* @see {@link https://discord.com/developers/docs/components/reference#text-input}
2107+
*/
2108+
export interface APITextInputComponent extends APIBaseTextInputComponent {
2109+
/**
2110+
* Text that appears on top of the text input field, max 45 characters
2111+
*/
2112+
label: string;
2113+
}
2114+
2115+
/**
2116+
* A text input component that may be used in modals.
2117+
*/
2118+
export interface APITextInputComponentInModal extends APIBaseTextInputComponent {}
2119+
20982120
export enum UnfurledMediaItemLoadingState {
20992121
Unknown,
21002122
Loading,
@@ -2305,6 +2327,12 @@ export interface APIContainerComponent extends APIBaseComponent<ComponentType.Co
23052327
components: APIComponentInContainer[];
23062328
}
23072329

2330+
export interface APILabelComponent extends APIBaseComponent<ComponentType.Label> {
2331+
label: string;
2332+
description?: string;
2333+
component: APIStringSelectComponentInModal | APITextInputComponentInModal;
2334+
}
2335+
23082336
/**
23092337
* @see {@link https://discord.com/developers/docs/resources/channel#message-snapshot-object}
23102338
*/

payloads/v9/_interactions/modalSubmit.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { APIBaseComponent } from '../channel';
1+
import type { APIBaseComponent, APILabelComponent } from '../channel';
22
import type {
33
APIBaseInteraction,
44
APIDMInteractionWrapper,
@@ -17,6 +17,10 @@ export interface ModalSubmitActionRowComponent extends APIBaseComponent<Componen
1717
components: ModalSubmitComponent[];
1818
}
1919

20+
export interface ModalSubmitLabelComponent extends APIBaseComponent<ComponentType.Label> {
21+
component: APILabelComponent;
22+
}
23+
2024
/**
2125
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-modal-submit-data-structure}
2226
*/
@@ -28,7 +32,7 @@ export interface APIModalSubmission {
2832
/**
2933
* A list of child components
3034
*/
31-
components: ModalSubmitActionRowComponent[];
35+
components: (ModalSubmitActionRowComponent | ModalSubmitLabelComponent)[];
3236
}
3337

3438
/**

0 commit comments

Comments
 (0)