feat: More label components and text display in modals (#1351)

This commit is contained in:
Jiralite
2025-09-05 11:47:26 +04:00
committed by GitHub
parent 36567c75e8
commit fa05a7503f
12 changed files with 184 additions and 32 deletions

View File

@@ -3,6 +3,7 @@ import type {
APIBaseInteraction,
APIDMInteractionWrapper,
APIGuildInteractionWrapper,
APIInteractionDataResolved,
ComponentType,
InteractionType,
} from '../mod.ts';
@@ -20,7 +21,30 @@ export interface APIModalSubmitStringSelectComponent extends APIBaseModalSubmitC
values: string[];
}
export type ModalSubmitComponent = APIModalSubmitStringSelectComponent | APIModalSubmitTextInputComponent;
export interface APIModalSubmitUserSelectComponent extends APIBaseModalSubmitComponent<ComponentType.UserSelect> {
values: string[];
}
export interface APIModalSubmitRoleSelectComponent extends APIBaseModalSubmitComponent<ComponentType.RoleSelect> {
values: string[];
}
export interface APIModalSubmitMentionableSelectComponent
extends APIBaseModalSubmitComponent<ComponentType.MentionableSelect> {
values: string[];
}
export interface APIModalSubmitChannelSelectComponent extends APIBaseModalSubmitComponent<ComponentType.ChannelSelect> {
values: string[];
}
export type ModalSubmitComponent =
| APIModalSubmitChannelSelectComponent
| APIModalSubmitMentionableSelectComponent
| APIModalSubmitRoleSelectComponent
| APIModalSubmitStringSelectComponent
| APIModalSubmitTextInputComponent
| APIModalSubmitUserSelectComponent;
export interface ModalSubmitActionRowComponent extends APIBaseComponent<ComponentType.ActionRow> {
components: APIModalSubmitTextInputComponent[];
@@ -36,6 +60,12 @@ export type APIModalSubmissionComponent = ModalSubmitActionRowComponent | ModalS
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-modal-submit-data-structure}
*/
export interface APIModalSubmission {
/**
* Data for users, members, channels, and roles in the modal's auto-populated select menus
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure}
*/
resolved?: APIInteractionDataResolved;
/**
* A developer-defined identifier for the component, max 100 characters
*/

View File

@@ -1,5 +1,10 @@
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v10.ts';
import type { APIActionRowComponent, APIComponentInModalActionRow, APILabelComponent } from '../channel.ts';
import type {
APIActionRowComponent,
APIComponentInModalActionRow,
APILabelComponent,
APITextDisplayComponent,
} from '../channel.ts';
import type { APIApplicationCommandOptionChoice } from './applicationCommands.ts';
/**
@@ -128,7 +133,8 @@ export interface APICommandAutocompleteInteractionResponseCallbackData {
export type APIModalInteractionResponseCallbackComponent =
| APIActionRowComponent<APIComponentInModalActionRow>
| APILabelComponent;
| APILabelComponent
| APITextDisplayComponent;
/**
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-modal}

View File

@@ -1898,6 +1898,12 @@ export interface APIBaseSelectMenuComponent<
* @defaultValue `false`
*/
disabled?: boolean;
/**
* Whether the component is required to answer in a modal.
*
* @defaultValue `true`
*/
required?: boolean;
}
/**
@@ -1931,10 +1937,6 @@ export interface APIStringSelectComponent extends APIBaseSelectMenuComponent<Com
* Specified choices in a select menu; max 25
*/
options: APISelectMenuOption[];
/**
* Whether this component is required in modals.
*/
required?: boolean;
}
/**
@@ -2457,7 +2459,7 @@ export type APIComponentInModalActionRow = APITextInputComponent;
/**
* @see {@link https://discord.com/developers/docs/components/reference#label-label-child-components}
*/
export type APIComponentInLabel = APIStringSelectComponent | APITextInputComponent;
export type APIComponentInLabel = APISelectMenuComponent | APITextInputComponent;
/**
* @see {@link https://discord.com/developers/docs/components/reference#section}

View File

@@ -3,6 +3,7 @@ import type {
APIBaseInteraction,
APIDMInteractionWrapper,
APIGuildInteractionWrapper,
APIInteractionDataResolved,
ComponentType,
InteractionType,
} from '../mod.ts';
@@ -20,7 +21,30 @@ export interface APIModalSubmitStringSelectComponent extends APIBaseModalSubmitC
values: string[];
}
export type ModalSubmitComponent = APIModalSubmitStringSelectComponent | APIModalSubmitTextInputComponent;
export interface APIModalSubmitUserSelectComponent extends APIBaseModalSubmitComponent<ComponentType.UserSelect> {
values: string[];
}
export interface APIModalSubmitRoleSelectComponent extends APIBaseModalSubmitComponent<ComponentType.RoleSelect> {
values: string[];
}
export interface APIModalSubmitMentionableSelectComponent
extends APIBaseModalSubmitComponent<ComponentType.MentionableSelect> {
values: string[];
}
export interface APIModalSubmitChannelSelectComponent extends APIBaseModalSubmitComponent<ComponentType.ChannelSelect> {
values: string[];
}
export type ModalSubmitComponent =
| APIModalSubmitChannelSelectComponent
| APIModalSubmitMentionableSelectComponent
| APIModalSubmitRoleSelectComponent
| APIModalSubmitStringSelectComponent
| APIModalSubmitTextInputComponent
| APIModalSubmitUserSelectComponent;
export interface ModalSubmitActionRowComponent extends APIBaseComponent<ComponentType.ActionRow> {
components: APIModalSubmitTextInputComponent[];
@@ -36,6 +60,12 @@ export type APIModalSubmissionComponent = ModalSubmitActionRowComponent | ModalS
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-modal-submit-data-structure}
*/
export interface APIModalSubmission {
/**
* Data for users, members, channels, and roles in the modal's auto-populated select menus
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure}
*/
resolved?: APIInteractionDataResolved;
/**
* A developer-defined identifier for the component, max 100 characters
*/

View File

@@ -1,5 +1,10 @@
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9.ts';
import type { APIActionRowComponent, APIComponentInModalActionRow, APILabelComponent } from '../channel.ts';
import type {
APIActionRowComponent,
APIComponentInModalActionRow,
APILabelComponent,
APITextDisplayComponent,
} from '../channel.ts';
import type { APIApplicationCommandOptionChoice } from './applicationCommands.ts';
/**
@@ -128,7 +133,8 @@ export interface APICommandAutocompleteInteractionResponseCallbackData {
export type APIModalInteractionResponseCallbackComponent =
| APIActionRowComponent<APIComponentInModalActionRow>
| APILabelComponent;
| APILabelComponent
| APITextDisplayComponent;
/**
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-modal}

View File

@@ -1897,6 +1897,12 @@ export interface APIBaseSelectMenuComponent<
* @defaultValue `false`
*/
disabled?: boolean;
/**
* Whether the component is required to answer in a modal.
*
* @defaultValue `true`
*/
required?: boolean;
}
/**
@@ -1930,10 +1936,6 @@ export interface APIStringSelectComponent extends APIBaseSelectMenuComponent<Com
* Specified choices in a select menu; max 25
*/
options: APISelectMenuOption[];
/**
* Whether this component is required in modals.
*/
required?: boolean;
}
/**
@@ -2456,7 +2458,7 @@ export type APIComponentInModalActionRow = APITextInputComponent;
/**
* @see {@link https://discord.com/developers/docs/components/reference#label-label-child-components}
*/
export type APIComponentInLabel = APIStringSelectComponent | APITextInputComponent;
export type APIComponentInLabel = APISelectMenuComponent | APITextInputComponent;
/**
* @see {@link https://discord.com/developers/docs/components/reference#section}

View File

@@ -3,6 +3,7 @@ import type {
APIBaseInteraction,
APIDMInteractionWrapper,
APIGuildInteractionWrapper,
APIInteractionDataResolved,
ComponentType,
InteractionType,
} from '../index';
@@ -20,7 +21,30 @@ export interface APIModalSubmitStringSelectComponent extends APIBaseModalSubmitC
values: string[];
}
export type ModalSubmitComponent = APIModalSubmitStringSelectComponent | APIModalSubmitTextInputComponent;
export interface APIModalSubmitUserSelectComponent extends APIBaseModalSubmitComponent<ComponentType.UserSelect> {
values: string[];
}
export interface APIModalSubmitRoleSelectComponent extends APIBaseModalSubmitComponent<ComponentType.RoleSelect> {
values: string[];
}
export interface APIModalSubmitMentionableSelectComponent
extends APIBaseModalSubmitComponent<ComponentType.MentionableSelect> {
values: string[];
}
export interface APIModalSubmitChannelSelectComponent extends APIBaseModalSubmitComponent<ComponentType.ChannelSelect> {
values: string[];
}
export type ModalSubmitComponent =
| APIModalSubmitChannelSelectComponent
| APIModalSubmitMentionableSelectComponent
| APIModalSubmitRoleSelectComponent
| APIModalSubmitStringSelectComponent
| APIModalSubmitTextInputComponent
| APIModalSubmitUserSelectComponent;
export interface ModalSubmitActionRowComponent extends APIBaseComponent<ComponentType.ActionRow> {
components: APIModalSubmitTextInputComponent[];
@@ -36,6 +60,12 @@ export type APIModalSubmissionComponent = ModalSubmitActionRowComponent | ModalS
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-modal-submit-data-structure}
*/
export interface APIModalSubmission {
/**
* Data for users, members, channels, and roles in the modal's auto-populated select menus
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure}
*/
resolved?: APIInteractionDataResolved;
/**
* A developer-defined identifier for the component, max 100 characters
*/

View File

@@ -1,5 +1,10 @@
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v10';
import type { APIActionRowComponent, APIComponentInModalActionRow, APILabelComponent } from '../channel';
import type {
APIActionRowComponent,
APIComponentInModalActionRow,
APILabelComponent,
APITextDisplayComponent,
} from '../channel';
import type { APIApplicationCommandOptionChoice } from './applicationCommands';
/**
@@ -128,7 +133,8 @@ export interface APICommandAutocompleteInteractionResponseCallbackData {
export type APIModalInteractionResponseCallbackComponent =
| APIActionRowComponent<APIComponentInModalActionRow>
| APILabelComponent;
| APILabelComponent
| APITextDisplayComponent;
/**
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-modal}

View File

@@ -1898,6 +1898,12 @@ export interface APIBaseSelectMenuComponent<
* @defaultValue `false`
*/
disabled?: boolean;
/**
* Whether the component is required to answer in a modal.
*
* @defaultValue `true`
*/
required?: boolean;
}
/**
@@ -1931,10 +1937,6 @@ export interface APIStringSelectComponent extends APIBaseSelectMenuComponent<Com
* Specified choices in a select menu; max 25
*/
options: APISelectMenuOption[];
/**
* Whether this component is required in modals.
*/
required?: boolean;
}
/**
@@ -2457,7 +2459,7 @@ export type APIComponentInModalActionRow = APITextInputComponent;
/**
* @see {@link https://discord.com/developers/docs/components/reference#label-label-child-components}
*/
export type APIComponentInLabel = APIStringSelectComponent | APITextInputComponent;
export type APIComponentInLabel = APISelectMenuComponent | APITextInputComponent;
/**
* @see {@link https://discord.com/developers/docs/components/reference#section}

View File

@@ -3,6 +3,7 @@ import type {
APIBaseInteraction,
APIDMInteractionWrapper,
APIGuildInteractionWrapper,
APIInteractionDataResolved,
ComponentType,
InteractionType,
} from '../index';
@@ -20,7 +21,30 @@ export interface APIModalSubmitStringSelectComponent extends APIBaseModalSubmitC
values: string[];
}
export type ModalSubmitComponent = APIModalSubmitStringSelectComponent | APIModalSubmitTextInputComponent;
export interface APIModalSubmitUserSelectComponent extends APIBaseModalSubmitComponent<ComponentType.UserSelect> {
values: string[];
}
export interface APIModalSubmitRoleSelectComponent extends APIBaseModalSubmitComponent<ComponentType.RoleSelect> {
values: string[];
}
export interface APIModalSubmitMentionableSelectComponent
extends APIBaseModalSubmitComponent<ComponentType.MentionableSelect> {
values: string[];
}
export interface APIModalSubmitChannelSelectComponent extends APIBaseModalSubmitComponent<ComponentType.ChannelSelect> {
values: string[];
}
export type ModalSubmitComponent =
| APIModalSubmitChannelSelectComponent
| APIModalSubmitMentionableSelectComponent
| APIModalSubmitRoleSelectComponent
| APIModalSubmitStringSelectComponent
| APIModalSubmitTextInputComponent
| APIModalSubmitUserSelectComponent;
export interface ModalSubmitActionRowComponent extends APIBaseComponent<ComponentType.ActionRow> {
components: APIModalSubmitTextInputComponent[];
@@ -36,6 +60,12 @@ export type APIModalSubmissionComponent = ModalSubmitActionRowComponent | ModalS
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-modal-submit-data-structure}
*/
export interface APIModalSubmission {
/**
* Data for users, members, channels, and roles in the modal's auto-populated select menus
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure}
*/
resolved?: APIInteractionDataResolved;
/**
* A developer-defined identifier for the component, max 100 characters
*/

View File

@@ -1,5 +1,10 @@
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9';
import type { APIActionRowComponent, APIComponentInModalActionRow, APILabelComponent } from '../channel';
import type {
APIActionRowComponent,
APIComponentInModalActionRow,
APILabelComponent,
APITextDisplayComponent,
} from '../channel';
import type { APIApplicationCommandOptionChoice } from './applicationCommands';
/**
@@ -128,7 +133,8 @@ export interface APICommandAutocompleteInteractionResponseCallbackData {
export type APIModalInteractionResponseCallbackComponent =
| APIActionRowComponent<APIComponentInModalActionRow>
| APILabelComponent;
| APILabelComponent
| APITextDisplayComponent;
/**
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-modal}

View File

@@ -1897,6 +1897,12 @@ export interface APIBaseSelectMenuComponent<
* @defaultValue `false`
*/
disabled?: boolean;
/**
* Whether the component is required to answer in a modal.
*
* @defaultValue `true`
*/
required?: boolean;
}
/**
@@ -1930,10 +1936,6 @@ export interface APIStringSelectComponent extends APIBaseSelectMenuComponent<Com
* Specified choices in a select menu; max 25
*/
options: APISelectMenuOption[];
/**
* Whether this component is required in modals.
*/
required?: boolean;
}
/**
@@ -2456,7 +2458,7 @@ export type APIComponentInModalActionRow = APITextInputComponent;
/**
* @see {@link https://discord.com/developers/docs/components/reference#label-label-child-components}
*/
export type APIComponentInLabel = APIStringSelectComponent | APITextInputComponent;
export type APIComponentInLabel = APISelectMenuComponent | APITextInputComponent;
/**
* @see {@link https://discord.com/developers/docs/components/reference#section}