Skip to content

Commit 97b1b64

Browse files
committed
fix: add missing id param to decorators + ActionRow.add_*
1 parent 137db4c commit 97b1b64

File tree

7 files changed

+128
-30
lines changed

7 files changed

+128
-30
lines changed

disnake/ui/action_row.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def add_button(
291291
url: Optional[str] = None,
292292
emoji: Optional[Union[str, Emoji, PartialEmoji]] = None,
293293
sku_id: Optional[int] = None,
294+
id: int = 0,
294295
) -> ButtonCompatibleActionRowT:
295296
"""Add a button to the action row. Can only be used if the action
296297
row holds message components.
@@ -326,6 +327,12 @@ def add_button(
326327
The ID of a purchasable SKU, for premium buttons.
327328
Premium buttons additionally cannot have a ``label``, ``url``, or ``emoji``.
328329
330+
.. versionadded:: 2.11
331+
id: :class:`int`
332+
The numeric identifier for the component.
333+
If left unset (i.e. the default ``0``) when sending a component, the API will assign
334+
sequential identifiers to the components in the message.
335+
329336
.. versionadded:: 2.11
330337
331338
Raises
@@ -336,6 +343,7 @@ def add_button(
336343
self.insert_item(
337344
len(self) if index is None else index,
338345
Button(
346+
id=id,
339347
style=style,
340348
label=label,
341349
disabled=disabled,
@@ -356,6 +364,7 @@ def add_string_select(
356364
max_values: int = 1,
357365
options: SelectOptionInput = MISSING,
358366
disabled: bool = False,
367+
id: int = 0,
359368
) -> SelectCompatibleActionRowT:
360369
"""Add a string select menu to the action row. Can only be used if the action
361370
row holds message components.
@@ -387,6 +396,12 @@ def add_string_select(
387396
as a list of labels, and a dict will be treated as a mapping of labels to values.
388397
disabled: :class:`bool`
389398
Whether the select is disabled or not.
399+
id: :class:`int`
400+
The numeric identifier for the component.
401+
If left unset (i.e. the default ``0``) when sending a component, the API will assign
402+
sequential identifiers to the components in the message.
403+
404+
.. versionadded:: 2.11
390405
391406
Raises
392407
------
@@ -395,6 +410,7 @@ def add_string_select(
395410
"""
396411
self.append_item(
397412
StringSelect(
413+
id=id,
398414
custom_id=custom_id,
399415
placeholder=placeholder,
400416
min_values=min_values,
@@ -416,6 +432,7 @@ def add_user_select(
416432
max_values: int = 1,
417433
disabled: bool = False,
418434
default_values: Optional[Sequence[SelectDefaultValueInputType[Union[User, Member]]]] = None,
435+
id: int = 0,
419436
) -> SelectCompatibleActionRowT:
420437
"""Add a user select menu to the action row. Can only be used if the action
421438
row holds message components.
@@ -447,6 +464,12 @@ def add_user_select(
447464
If set, the number of items must be within the bounds set by ``min_values`` and ``max_values``.
448465
449466
.. versionadded:: 2.10
467+
id: :class:`int`
468+
The numeric identifier for the component.
469+
If left unset (i.e. the default ``0``) when sending a component, the API will assign
470+
sequential identifiers to the components in the message.
471+
472+
.. versionadded:: 2.11
450473
451474
Raises
452475
------
@@ -455,6 +478,7 @@ def add_user_select(
455478
"""
456479
self.append_item(
457480
UserSelect(
481+
id=id,
458482
custom_id=custom_id,
459483
placeholder=placeholder,
460484
min_values=min_values,
@@ -474,6 +498,7 @@ def add_role_select(
474498
max_values: int = 1,
475499
disabled: bool = False,
476500
default_values: Optional[Sequence[SelectDefaultValueInputType[Role]]] = None,
501+
id: int = 0,
477502
) -> SelectCompatibleActionRowT:
478503
"""Add a role select menu to the action row. Can only be used if the action
479504
row holds message components.
@@ -505,6 +530,12 @@ def add_role_select(
505530
If set, the number of items must be within the bounds set by ``min_values`` and ``max_values``.
506531
507532
.. versionadded:: 2.10
533+
id: :class:`int`
534+
The numeric identifier for the component.
535+
If left unset (i.e. the default ``0``) when sending a component, the API will assign
536+
sequential identifiers to the components in the message.
537+
538+
.. versionadded:: 2.11
508539
509540
Raises
510541
------
@@ -513,6 +544,7 @@ def add_role_select(
513544
"""
514545
self.append_item(
515546
RoleSelect(
547+
id=id,
516548
custom_id=custom_id,
517549
placeholder=placeholder,
518550
min_values=min_values,
@@ -534,6 +566,7 @@ def add_mentionable_select(
534566
default_values: Optional[
535567
Sequence[SelectDefaultValueMultiInputType[Union[User, Member, Role]]]
536568
] = None,
569+
id: int = 0,
537570
) -> SelectCompatibleActionRowT:
538571
"""Add a mentionable (user/member/role) select menu to the action row. Can only be used if the action
539572
row holds message components.
@@ -567,6 +600,12 @@ def add_mentionable_select(
567600
Note that unlike other select menu types, this does not support :class:`.Object`\\s due to ambiguities.
568601
569602
.. versionadded:: 2.10
603+
id: :class:`int`
604+
The numeric identifier for the component.
605+
If left unset (i.e. the default ``0``) when sending a component, the API will assign
606+
sequential identifiers to the components in the message.
607+
608+
.. versionadded:: 2.11
570609
571610
Raises
572611
------
@@ -575,6 +614,7 @@ def add_mentionable_select(
575614
"""
576615
self.append_item(
577616
MentionableSelect(
617+
id=id,
578618
custom_id=custom_id,
579619
placeholder=placeholder,
580620
min_values=min_values,
@@ -595,6 +635,7 @@ def add_channel_select(
595635
disabled: bool = False,
596636
channel_types: Optional[List[ChannelType]] = None,
597637
default_values: Optional[Sequence[SelectDefaultValueInputType[AnyChannel]]] = None,
638+
id: int = 0,
598639
) -> SelectCompatibleActionRowT:
599640
"""Add a channel select menu to the action row. Can only be used if the action
600641
row holds message components.
@@ -629,6 +670,12 @@ def add_channel_select(
629670
If set, the number of items must be within the bounds set by ``min_values`` and ``max_values``.
630671
631672
.. versionadded:: 2.10
673+
id: :class:`int`
674+
The numeric identifier for the component.
675+
If left unset (i.e. the default ``0``) when sending a component, the API will assign
676+
sequential identifiers to the components in the message.
677+
678+
.. versionadded:: 2.11
632679
633680
Raises
634681
------
@@ -637,6 +684,7 @@ def add_channel_select(
637684
"""
638685
self.append_item(
639686
ChannelSelect(
687+
id=id,
640688
custom_id=custom_id,
641689
placeholder=placeholder,
642690
min_values=min_values,
@@ -659,6 +707,7 @@ def add_text_input(
659707
required: bool = True,
660708
min_length: Optional[int] = None,
661709
max_length: Optional[int] = None,
710+
id: int = 0,
662711
) -> TextInputCompatibleActionRowT:
663712
"""Add a text input to the action row. Can only be used if the action
664713
row holds modal components.
@@ -688,6 +737,12 @@ def add_text_input(
688737
The minimum length of the text input.
689738
max_length: Optional[:class:`int`]
690739
The maximum length of the text input.
740+
id: :class:`int`
741+
The numeric identifier for the component.
742+
If left unset (i.e. the default ``0``) when sending a component, the API will assign
743+
sequential identifiers to the components in the message.
744+
745+
.. versionadded:: 2.11
691746
692747
Raises
693748
------
@@ -696,6 +751,7 @@ def add_text_input(
696751
"""
697752
self.append_item(
698753
TextInput(
754+
id=id,
699755
label=label,
700756
custom_id=custom_id,
701757
style=style,

disnake/ui/button.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ def button(
301301
disabled: bool = False,
302302
style: ButtonStyle = ButtonStyle.secondary,
303303
emoji: Optional[Union[str, Emoji, PartialEmoji]] = None,
304+
id: int = 0,
304305
row: Optional[int] = None,
305306
) -> Callable[[ItemCallbackType[V_co, Button[V_co]]], DecoratedItem[Button[V_co]]]: ...
306307

@@ -347,6 +348,12 @@ def button(
347348
emoji: Optional[Union[:class:`str`, :class:`.Emoji`, :class:`.PartialEmoji`]]
348349
The emoji of the button. This can be in string form or a :class:`.PartialEmoji`
349350
or a full :class:`.Emoji`.
351+
id: :class:`int`
352+
The numeric identifier for the component.
353+
If left unset (i.e. the default ``0``) when sending a component, the API will assign
354+
sequential identifiers to the components in the message.
355+
356+
.. versionadded:: 2.11
350357
row: Optional[:class:`int`]
351358
The relative row this button belongs to. A Discord component can only have 5
352359
rows. By default, items are arranged automatically into those 5 rows. If you'd

disnake/ui/select/channel.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def channel_select(
207207
disabled: bool = False,
208208
channel_types: Optional[List[ChannelType]] = None,
209209
default_values: Optional[Sequence[SelectDefaultValueInputType[AnyChannel]]] = None,
210+
id: int = 0,
210211
row: Optional[int] = None,
211212
) -> Callable[
212213
[ItemCallbackType[V_co, ChannelSelect[V_co]]], DecoratedItem[ChannelSelect[V_co]]
@@ -244,12 +245,6 @@ def channel_select(
244245
custom_id: :class:`str`
245246
The ID of the select menu that gets received during an interaction.
246247
It is recommended not to set this parameter to prevent conflicts.
247-
row: Optional[:class:`int`]
248-
The relative row this select menu belongs to. A Discord component can only have 5
249-
rows. By default, items are arranged automatically into those 5 rows. If you'd
250-
like to control the relative positioning of the row then passing an index is advised.
251-
For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
252-
ordering. The row number must be between 0 and 4 (i.e. zero indexed).
253248
min_values: :class:`int`
254249
The minimum number of items that must be chosen for this select menu.
255250
Defaults to 1 and must be between 1 and 25.
@@ -266,5 +261,17 @@ def channel_select(
266261
If set, the number of items must be within the bounds set by ``min_values`` and ``max_values``.
267262
268263
.. versionadded:: 2.10
264+
id: :class:`int`
265+
The numeric identifier for the component.
266+
If left unset (i.e. the default ``0``) when sending a component, the API will assign
267+
sequential identifiers to the components in the message.
268+
269+
.. versionadded:: 2.11
270+
row: Optional[:class:`int`]
271+
The relative row this select menu belongs to. A Discord component can only have 5
272+
rows. By default, items are arranged automatically into those 5 rows. If you'd
273+
like to control the relative positioning of the row then passing an index is advised.
274+
For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
275+
ordering. The row number must be between 0 and 4 (i.e. zero indexed).
269276
"""
270277
return _create_decorator(cls, **kwargs)

disnake/ui/select/mentionable.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def mentionable_select(
182182
default_values: Optional[
183183
Sequence[SelectDefaultValueMultiInputType[Union[User, Member, Role]]]
184184
] = None,
185+
id: int = 0,
185186
row: Optional[int] = None,
186187
) -> Callable[
187188
[ItemCallbackType[V_co, MentionableSelect[V_co]]], DecoratedItem[MentionableSelect[V_co]]
@@ -219,12 +220,6 @@ def mentionable_select(
219220
custom_id: :class:`str`
220221
The ID of the select menu that gets received during an interaction.
221222
It is recommended not to set this parameter to prevent conflicts.
222-
row: Optional[:class:`int`]
223-
The relative row this select menu belongs to. A Discord component can only have 5
224-
rows. By default, items are arranged automatically into those 5 rows. If you'd
225-
like to control the relative positioning of the row then passing an index is advised.
226-
For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
227-
ordering. The row number must be between 0 and 4 (i.e. zero indexed).
228223
min_values: :class:`int`
229224
The minimum number of items that must be chosen for this select menu.
230225
Defaults to 1 and must be between 1 and 25.
@@ -240,5 +235,17 @@ def mentionable_select(
240235
Note that unlike other select menu types, this does not support :class:`.Object`\\s due to ambiguities.
241236
242237
.. versionadded:: 2.10
238+
id: :class:`int`
239+
The numeric identifier for the component.
240+
If left unset (i.e. the default ``0``) when sending a component, the API will assign
241+
sequential identifiers to the components in the message.
242+
243+
.. versionadded:: 2.11
244+
row: Optional[:class:`int`]
245+
The relative row this select menu belongs to. A Discord component can only have 5
246+
rows. By default, items are arranged automatically into those 5 rows. If you'd
247+
like to control the relative positioning of the row then passing an index is advised.
248+
For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
249+
ordering. The row number must be between 0 and 4 (i.e. zero indexed).
243250
"""
244251
return _create_decorator(cls, **kwargs)

disnake/ui/select/role.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def role_select(
169169
max_values: int = 1,
170170
disabled: bool = False,
171171
default_values: Optional[Sequence[SelectDefaultValueInputType[Role]]] = None,
172+
id: int = 0,
172173
row: Optional[int] = None,
173174
) -> Callable[[ItemCallbackType[V_co, RoleSelect[V_co]]], DecoratedItem[RoleSelect[V_co]]]: ...
174175

@@ -204,12 +205,6 @@ def role_select(
204205
custom_id: :class:`str`
205206
The ID of the select menu that gets received during an interaction.
206207
It is recommended not to set this parameter to prevent conflicts.
207-
row: Optional[:class:`int`]
208-
The relative row this select menu belongs to. A Discord component can only have 5
209-
rows. By default, items are arranged automatically into those 5 rows. If you'd
210-
like to control the relative positioning of the row then passing an index is advised.
211-
For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
212-
ordering. The row number must be between 0 and 4 (i.e. zero indexed).
213208
min_values: :class:`int`
214209
The minimum number of items that must be chosen for this select menu.
215210
Defaults to 1 and must be between 1 and 25.
@@ -223,5 +218,17 @@ def role_select(
223218
If set, the number of items must be within the bounds set by ``min_values`` and ``max_values``.
224219
225220
.. versionadded:: 2.10
221+
id: :class:`int`
222+
The numeric identifier for the component.
223+
If left unset (i.e. the default ``0``) when sending a component, the API will assign
224+
sequential identifiers to the components in the message.
225+
226+
.. versionadded:: 2.11
227+
row: Optional[:class:`int`]
228+
The relative row this select menu belongs to. A Discord component can only have 5
229+
rows. By default, items are arranged automatically into those 5 rows. If you'd
230+
like to control the relative positioning of the row then passing an index is advised.
231+
For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
232+
ordering. The row number must be between 0 and 4 (i.e. zero indexed).
226233
"""
227234
return _create_decorator(cls, **kwargs)

disnake/ui/select/string.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def string_select(
273273
max_values: int = 1,
274274
options: SelectOptionInput = ...,
275275
disabled: bool = False,
276+
id: int = 0,
276277
row: Optional[int] = None,
277278
) -> Callable[[ItemCallbackType[V_co, StringSelect[V_co]]], DecoratedItem[StringSelect[V_co]]]: ...
278279

@@ -311,12 +312,6 @@ def string_select(
311312
custom_id: :class:`str`
312313
The ID of the select menu that gets received during an interaction.
313314
It is recommended not to set this parameter to prevent conflicts.
314-
row: Optional[:class:`int`]
315-
The relative row this select menu belongs to. A Discord component can only have 5
316-
rows. By default, items are arranged automatically into those 5 rows. If you'd
317-
like to control the relative positioning of the row then passing an index is advised.
318-
For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
319-
ordering. The row number must be between 0 and 4 (i.e. zero indexed).
320315
min_values: :class:`int`
321316
The minimum number of items that must be chosen for this select menu.
322317
Defaults to 1 and must be between 1 and 25.
@@ -334,6 +329,18 @@ def string_select(
334329
335330
disabled: :class:`bool`
336331
Whether the select is disabled. Defaults to ``False``.
332+
id: :class:`int`
333+
The numeric identifier for the component.
334+
If left unset (i.e. the default ``0``) when sending a component, the API will assign
335+
sequential identifiers to the components in the message.
336+
337+
.. versionadded:: 2.11
338+
row: Optional[:class:`int`]
339+
The relative row this select menu belongs to. A Discord component can only have 5
340+
rows. By default, items are arranged automatically into those 5 rows. If you'd
341+
like to control the relative positioning of the row then passing an index is advised.
342+
For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
343+
ordering. The row number must be between 0 and 4 (i.e. zero indexed).
337344
"""
338345
return _create_decorator(cls, **kwargs)
339346

0 commit comments

Comments
 (0)