1
1
from __future__ import annotations
2
2
3
3
from functools import partial
4
+ from collections .abc import Sequence
4
5
from typing import TYPE_CHECKING , ClassVar , Iterator , TypeVar
5
6
6
7
from ..components import ActionRow as ActionRowComponent
7
- from ..components import SelectOption , _component_factory
8
+ from ..components import SelectOption , SelectDefaultValue , _component_factory
8
9
from ..enums import ButtonStyle , ChannelType , ComponentType
9
10
from ..utils import find , get
10
11
from .button import Button
@@ -210,6 +211,53 @@ def add_button(
210
211
211
212
return self .add_item (button )
212
213
214
+ @overload
215
+ def add_select (
216
+ self ,
217
+ select_type : Literal [ComponentType .string_select ] = ...,
218
+ * ,
219
+ custom_id : str | None = ...,
220
+ placeholder : str | None = ...,
221
+ min_values : int = ...,
222
+ max_values : int = ...,
223
+ options : list [SelectOption ] | None = ...,
224
+ disabled : bool = ...,
225
+ id : int | None = ...,
226
+ ) -> None : ...
227
+
228
+ @overload
229
+ def add_select (
230
+ self ,
231
+ select_type : Literal [ComponentType .channel_select ] = ...,
232
+ * ,
233
+ custom_id : str | None = ...,
234
+ placeholder : str | None = ...,
235
+ min_values : int = ...,
236
+ max_values : int = ...,
237
+ channel_types : list [ChannelType ] | None = ...,
238
+ disabled : bool = ...,
239
+ id : int | None = ...,
240
+ default_values : Sequence [SelectDefaultValue ] | None = ...,
241
+ ) -> None : ...
242
+
243
+ @overload
244
+ def add_select (
245
+ self ,
246
+ select_type : Literal [
247
+ ComponentType .user_select ,
248
+ ComponentType .role_select ,
249
+ ComponentType .mentionable_select ,
250
+ ] = ...,
251
+ * ,
252
+ custom_id : str | None = ...,
253
+ placeholder : str | None = ...,
254
+ min_values : int = ...,
255
+ max_values : int = ...,
256
+ disabled : bool = ...,
257
+ id : int | None = ...,
258
+ default_values : Sequence [SelectDefaultValue ] | None = ...,
259
+ ) -> None : ...
260
+
213
261
def add_select (
214
262
self ,
215
263
select_type : ComponentType = ComponentType .string_select ,
@@ -222,6 +270,7 @@ def add_select(
222
270
channel_types : list [ChannelType ] | None = None ,
223
271
disabled : bool = False ,
224
272
id : int | None = None ,
273
+ default_values : Sequence [SelectDefaultValue ] | None = None ,
225
274
) -> Self :
226
275
"""Adds a :class:`Select` to the container.
227
276
@@ -256,6 +305,11 @@ def add_select(
256
305
Whether the select is disabled or not. Defaults to ``False``.
257
306
id: Optional[:class:`int`]
258
307
The select menu's ID.
308
+ default_values: Optional[Sequence[Union[:class:`discord.SelectDefaultValue`, :class:`discord.abc.Snowflake`]]]
309
+ The default values of this select. Only applicable if :attr:`.select_type` is not :attr:`discord.ComponentType.string_select`.
310
+
311
+ These can be either :class:`discord.SelectDefaultValue` instances or models, which will be converted into :class:`discord.SelectDefaultValue`
312
+ instances.
259
313
"""
260
314
261
315
select = Select (
@@ -268,6 +322,7 @@ def add_select(
268
322
channel_types = channel_types or [],
269
323
disabled = disabled ,
270
324
id = id ,
325
+ default_values = default_values
271
326
)
272
327
273
328
return self .add_item (select )
0 commit comments