@@ -78,10 +78,14 @@ class Button(Item[V]):
7878
7979 .. warning::
8080
81- This parameter does not work with V2 components or with more than 25 items in your view .
81+ This parameter does not work in :class:`ActionRow` .
8282
8383 id: Optional[:class:`int`]
8484 The button's ID.
85+ priority: Optional[:class:`int`]
86+ Only works in :class:`ActionRow`. Any integer greater than 0. If specified, decides the position
87+ of the button in this row instead of going by order of addition. The lower this number, the earlier its position.
88+ The ActionRow's children will be reordered when the View containing this button is sent.
8589 """
8690
8791 __item_repr_attributes__ : tuple [str , ...] = (
@@ -94,6 +98,7 @@ class Button(Item[V]):
9498 "row" ,
9599 "custom_id" ,
96100 "id" ,
101+ "priority" ,
97102 )
98103
99104 def __init__ (
@@ -108,6 +113,7 @@ def __init__(
108113 sku_id : int | None = None ,
109114 row : int | None = None ,
110115 id : int | None = None ,
116+ priority : int | None = None ,
111117 ):
112118 super ().__init__ ()
113119 if label and len (str (label )) > 80 :
@@ -120,11 +126,14 @@ def __init__(
120126 raise TypeError ("cannot mix both url and sku_id with Button" )
121127 if custom_id is not None and sku_id is not None :
122128 raise TypeError ("cannot mix both sku_id and custom_id with Button" )
129+ if priority and (priority < 0 or not isinstance (priority , int )):
130+ raise ValueError ("priority must be an integer greater than 0" )
123131
124132 if not isinstance (custom_id , str ) and custom_id is not None :
125133 raise TypeError (
126134 f"expected custom_id to be str, not { custom_id .__class__ .__name__ } "
127135 )
136+ self .priority : int | None = priority
128137
129138 self ._provided_custom_id = custom_id is not None
130139 if url is None and custom_id is None and sku_id is None :
@@ -294,6 +303,7 @@ def button(
294303 emoji : str | GuildEmoji | AppEmoji | PartialEmoji | None = None ,
295304 row : int | None = None ,
296305 id : int | None = None ,
306+ priority : int | None = None ,
297307) -> Callable [[ItemCallbackType [Button [V ]]], Button [V ]]:
298308 """A decorator that attaches a button to a component.
299309
@@ -328,6 +338,15 @@ def button(
328338 like to control the relative positioning of the row then passing an index is advised.
329339 For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic
330340 ordering. The row number must be between 0 and 4 (i.e. zero indexed).
341+
342+ .. warning::
343+
344+ This parameter does not work in :class:`ActionRow`.
345+
346+ priority: Optional[:class:`int`]
347+ Only works in :class:`ActionRow`. Any integer greater than 0. If specified, decides the position
348+ of the button in this row instead of going by order of addition. The lower this number, the earlier its position.
349+ The ActionRow's children will be reordered when the View containing it is sent. A priority of ``None`` will be ordered after any specified priority.
331350 """
332351
333352 def decorator (func : ItemCallbackType ) -> ItemCallbackType :
@@ -344,6 +363,7 @@ def decorator(func: ItemCallbackType) -> ItemCallbackType:
344363 "emoji" : emoji ,
345364 "row" : row ,
346365 "id" : id ,
366+ "priority" : priority
347367 }
348368 return func
349369
0 commit comments