88 RoleSelectMenuComponentData ,
99 RoleSelectMenuInteraction ,
1010 SelectMenuComponentOptionData ,
11+ Snowflake ,
1112 StringSelectMenuInteraction ,
1213 StringSelectMenuOptionBuilder ,
1314 UserSelectMenuComponentData ,
@@ -24,6 +25,7 @@ import {
2425 CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData ,
2526 CommandKitSelectMenuBuilderOnEnd ,
2627} from './common' ;
28+ import { applyDefaultOptionalComponentBehavior } from '../../common/element' ;
2729
2830/**
2931 * Type for the common properties shared by all select menu builders.
@@ -39,8 +41,10 @@ export interface CommonSelectMenuProps<T, C> {
3941 * Type for the base select menu component data.
4042 */
4143export interface SelectMenuProps < T , C >
42- extends Partial < Omit < BaseSelectMenuComponentData , 'type' > > ,
43- CommonSelectMenuProps < T , C > { }
44+ extends Partial < Omit < BaseSelectMenuComponentData , 'type' | 'required' > > ,
45+ CommonSelectMenuProps < T , C > {
46+ required ?: boolean ;
47+ }
4448
4549/**
4650 * The properties for a string select menu component.
@@ -83,9 +87,13 @@ export type ResolveBuilderInteraction<T> = T extends StringSelectMenuKit
8387 */
8488function applyPropsToBuilder < B extends CommonBuilderKit > (
8589 builder : B ,
86- props : Partial < Omit < BaseSelectMenuComponentData , 'type' > > &
87- CommonSelectMenuProps < ResolveBuilderInteraction < B > , B > ,
90+ props : Partial < Omit < BaseSelectMenuComponentData , 'type' | 'required' > > &
91+ CommonSelectMenuProps < ResolveBuilderInteraction < B > , B > & {
92+ required ?: boolean ;
93+ } ,
8894) {
95+ applyDefaultOptionalComponentBehavior ( props ) ;
96+
8997 builder . setCustomId ( props . customId ?? `select-menu::${ crypto . randomUUID ( ) } ` ) ;
9098
9199 if ( props . maxValues != null ) {
@@ -116,6 +124,10 @@ function applyPropsToBuilder<B extends CommonBuilderKit>(
116124 // @ts -ignore
117125 builder . onSelect ( props . onSelect , props . options ) ;
118126 }
127+
128+ if ( props . required != null ) {
129+ builder . setRequired ( props . required ) ;
130+ }
119131}
120132
121133/**
@@ -182,8 +194,10 @@ export function StringSelectMenuOption(props: StringSelectMenuOptionProps) {
182194 * The UserSelectMenu component.
183195 */
184196export interface UserSelectMenuProps
185- extends Partial < Omit < UserSelectMenuComponentData , 'type' > > ,
186- CommonSelectMenuProps < UserSelectMenuInteraction , UserSelectMenuKit > { }
197+ extends Partial < Omit < UserSelectMenuComponentData , 'type' | 'defaultValues' > > ,
198+ CommonSelectMenuProps < UserSelectMenuInteraction , UserSelectMenuKit > {
199+ defaultValues ?: MaybeArray < string | Snowflake > ;
200+ }
187201
188202/**
189203 * The UserSelectMenu component.
0 commit comments