3939 from .types .components import InputText as InputTextComponentPayload
4040 from .types .components import SelectMenu as SelectMenuPayload
4141 from .types .components import SelectOption as SelectOptionPayload
42+ from .types .components import SelectDefaultValue as SelectDefaultValuePayload
43+ from .types .components import SelectMenuDefaultValueType
4244
4345__all__ = (
4446 "Component" ,
4547 "ActionRow" ,
4648 "Button" ,
4749 "SelectMenu" ,
4850 "SelectOption" ,
51+ "SelectDefaultValue" ,
4952 "InputText" ,
5053)
5154
@@ -328,6 +331,9 @@ class SelectMenu(Component):
328331 except for :attr:`ComponentType.channel_select`.
329332 disabled: :class:`bool`
330333 Whether the select is disabled or not.
334+ default_values: List[:class:`SelectDefaultValue`]
335+ A list of options that are selected by default for select menus of type user, role, channel and mentionable.
336+ Will be an empty list for component type :attr:`ComponentType.string_select`.
331337 """
332338
333339 __slots__ : tuple [str , ...] = (
@@ -338,6 +344,7 @@ class SelectMenu(Component):
338344 "options" ,
339345 "channel_types" ,
340346 "disabled" ,
347+ "default_values" ,
341348 )
342349
343350 __repr_info__ : ClassVar [tuple [str , ...]] = __slots__
@@ -355,6 +362,7 @@ def __init__(self, data: SelectMenuPayload):
355362 self .channel_types : list [ChannelType ] = [
356363 try_enum (ChannelType , ct ) for ct in data .get ("channel_types" , [])
357364 ]
365+ self .default_values : list [SelectDefaultValue ] = []
358366
359367 def to_dict (self ) -> SelectMenuPayload :
360368 payload : SelectMenuPayload = {
@@ -371,6 +379,8 @@ def to_dict(self) -> SelectMenuPayload:
371379 payload ["channel_types" ] = [ct .value for ct in self .channel_types ]
372380 if self .placeholder :
373381 payload ["placeholder" ] = self .placeholder
382+ if self .type is ComponentType .role_select and self .default_values :
383+ payload ["default_values" ] = []
374384
375385 return payload
376386
@@ -494,6 +504,63 @@ def to_dict(self) -> SelectOptionPayload:
494504 return payload
495505
496506
507+ class SelectDefaultValue :
508+ """Represents a :class:`discord.SelectMenu`'s default option for user, role, channel and mentionable select menu types.
509+
510+ These can be created by users.
511+
512+ .. versionadded:: 2.7
513+
514+ Attributes
515+ ----------
516+ id: :class:`int`
517+ The snowflake id of the default option.
518+ type: :class:`SelectMenuDefaultValueType`
519+ The type of the default value. This is not displayed to users.
520+ """
521+
522+ __slots__ : tuple [str , ...] = (
523+ "id" ,
524+ "type" ,
525+ )
526+
527+ def __init__ (
528+ self ,
529+ * ,
530+ id : int ,
531+ type : SelectMenuDefaultValueType
532+ ) -> None :
533+ self .id = id
534+ self .type = type
535+
536+
537+
538+ def __repr__ (self ) -> str :
539+ return (
540+ "<SelectDefaultValue"
541+ f" id={ self .id !r} type={ self .type !r} >"
542+ )
543+
544+ def __str__ (self ) -> str :
545+ return f"{ self .id } { self .type } "
546+
547+ @classmethod
548+ def from_dict (cls , data : SelectDefaultValuePayload ) -> SelectDefaultValue :
549+
550+ return cls (
551+ id = data ["id" ],
552+ type = data ["type" ],
553+ )
554+
555+ def to_dict (self ) -> SelectDefaultValuePayload :
556+ payload : SelectDefaultValuePayload = {
557+ "id" : self .id ,
558+ "type" : self .type ,
559+ }
560+
561+ return payload
562+
563+
497564def _component_factory (data : ComponentPayload ) -> Component :
498565 component_type = data ["type" ]
499566 if component_type == 1 :
0 commit comments