@@ -77,26 +77,31 @@ class SelectMenu(ComponentMixin):
7777 placeholder="Check out my options. :)",
7878 custom_id="menu_component",
7979 )
80- :ivar ComponentType type: The type of select menu. Always defaults to ``3``.
80+ :ivar ComponentType type: The type of select menu. If not given, it defaults to ``ComponentType.SELECT`` (``STRING_SELECT``)
8181 :ivar str custom_id: The customized "ID" of the select menu.
82- :ivar List[SelectOption] options: The list of select options in the select menu.
82+ :ivar Optional[ List[SelectOption]] options: The list of select options in the select menu. This only applies to String-based selects .
8383 :ivar Optional[str] placeholder?: The placeholder of the select menu.
8484 :ivar Optional[int] min_values?: The minimum "options"/values to choose from the component.
8585 :ivar Optional[int] max_values?: The maximum "options"/values to choose from the component.
8686 :ivar Optional[bool] disabled?: Whether the select menu is unable to be used.
87+ :ivar Optional[List[int]] channel_types: Optional channel types to filter/whitelist. Only works with the CHANNEL_SELECT type.
8788 """
8889
8990 type : ComponentType = field (converter = ComponentType , default = ComponentType .SELECT )
9091 custom_id : str = field ()
91- options : List [SelectOption ] = field (converter = convert_list (SelectOption ))
92+ options : Optional [List [SelectOption ]] = field (
93+ converter = convert_list (SelectOption ), default = None
94+ )
9295 placeholder : Optional [str ] = field (default = None )
9396 min_values : Optional [int ] = field (default = None )
9497 max_values : Optional [int ] = field (default = None )
9598 disabled : Optional [bool ] = field (default = None )
99+ channel_types : Optional [List [int ]] = field (default = None )
96100
97101 def __attrs_post_init__ (self ) -> None :
98102 self ._json .update ({"type" : self .type .value })
99- self ._json .update ({"options" : [option ._json for option in self .options ]})
103+ if self .options :
104+ self ._json .update ({"options" : [option ._json for option in self .options ]})
100105
101106
102107@define ()
@@ -284,10 +289,14 @@ class ActionRow(ComponentMixin):
284289 def __attrs_post_init__ (self ) -> None :
285290 for component in self .components :
286291 if isinstance (component , SelectMenu ):
287- component ._json ["options" ] = [
288- option ._json if isinstance (option , SelectOption ) else option
289- for option in component ._json ["options" ]
290- ]
292+ component ._json ["options" ] = (
293+ [
294+ option ._json if isinstance (option , SelectOption ) else option
295+ for option in component ._json ["options" ]
296+ ]
297+ if component ._json .get ("options" )
298+ else []
299+ )
291300 self .components = (
292301 [Component (** component ._json ) for component in self .components ]
293302 if self ._json .get ("components" )
@@ -323,10 +332,14 @@ def __check_action_row():
323332 action_row if isinstance (action_row , list ) else action_row .components
324333 ):
325334 if isinstance (component , SelectMenu ):
326- component ._json ["options" ] = [
327- option if isinstance (option , dict ) else option ._json
328- for option in component .options
329- ]
335+ component ._json ["options" ] = (
336+ [
337+ option if isinstance (option , dict ) else option ._json
338+ for option in component .options
339+ ]
340+ if component ._json .get ("options" )
341+ else []
342+ )
330343
331344 _components .append (
332345 {
@@ -367,10 +380,14 @@ def __check_components():
367380 ):
368381 for component in components :
369382 if isinstance (component , SelectMenu ):
370- component ._json ["options" ] = [
371- options if isinstance (options , dict ) else options ._json
372- for options in component ._json ["options" ]
373- ]
383+ component ._json ["options" ] = (
384+ [
385+ options if isinstance (options , dict ) else options ._json
386+ for options in component ._json ["options" ]
387+ ]
388+ if component ._json .get ("options" )
389+ else []
390+ )
374391
375392 _components = [
376393 {
@@ -397,10 +414,14 @@ def __check_components():
397414 return _components
398415 elif isinstance (components , SelectMenu ):
399416 _components : List [dict ] = [{"type" : 1 , "components" : []}]
400- components ._json ["options" ] = [
401- options if isinstance (options , dict ) else options ._json
402- for options in components ._json ["options" ]
403- ]
417+ components ._json ["options" ] = (
418+ [
419+ options if isinstance (options , dict ) else options ._json
420+ for options in components ._json ["options" ]
421+ ]
422+ if components ._json .get ("options" )
423+ else []
424+ )
404425
405426 _components [0 ]["components" ] = (
406427 [components ._json ]
0 commit comments