Skip to content

Commit 20aae0f

Browse files
authored
no
1 parent bdb6d21 commit 20aae0f

File tree

2 files changed

+1
-36
lines changed

2 files changed

+1
-36
lines changed

discord/ui/action_row.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,6 @@ def _set_components(self, items: list[Item]):
9494
for item in items:
9595
self._add_component_from_item(item)
9696

97-
def _reorder(self):
98-
items = self.children
99-
if not any([isinstance(b, Select) for b in self.children]):
100-
a, b = [], []
101-
for i in items:
102-
if i.priority is None:
103-
b.append(i)
104-
else:
105-
a.append(i)
106-
items = sorted(a, key=lambda c: c.priority) + b
107-
self.children = items
108-
self._set_components(items)
109-
11097
def add_item(self, item: Item) -> Self:
11198
"""Adds an item to the action row.
11299
@@ -183,7 +170,6 @@ def add_button(
183170
emoji: str | GuildEmoji | AppEmoji | PartialEmoji | None = None,
184171
sku_id: int | None = None,
185172
id: int | None = None,
186-
priority: int | None = None,
187173
) -> Self:
188174
"""Adds a :class:`Button` to the action row.
189175
@@ -209,10 +195,6 @@ def add_button(
209195
The ID of the SKU this button refers to.
210196
id: Optional[:class:`int`]
211197
The button's ID.
212-
priority: Optional[:class:`int`]
213-
An integer greater than 0. If specified, decides the position
214-
of the button in this row instead of going by order of addition. The lower this number, the earlier its position.
215-
This ActionRow's children will be reordered when the View containing it is sent. A priority of ``None`` will be ordered after any specified priority.
216198
"""
217199

218200
button = Button(
@@ -224,7 +206,6 @@ def add_button(
224206
emoji=emoji,
225207
sku_id=sku_id,
226208
id=id,
227-
priority=priority,
228209
)
229210

230211
return self.add_item(button)
@@ -355,7 +336,7 @@ def walk_items(self) -> Iterator[Item]:
355336
yield from self.children
356337

357338
def to_component_dict(self) -> ActionRowPayload:
358-
self._reorder()
339+
self._set_components()
359340
return self._underlying.to_dict()
360341

361342
@classmethod

discord/ui/button.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ class Button(Item[V]):
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.
8985
"""
9086

9187
__item_repr_attributes__: tuple[str, ...] = (
@@ -98,7 +94,6 @@ class Button(Item[V]):
9894
"row",
9995
"custom_id",
10096
"id",
101-
"priority",
10297
)
10398

10499
def __init__(
@@ -113,7 +108,6 @@ def __init__(
113108
sku_id: int | None = None,
114109
row: int | None = None,
115110
id: int | None = None,
116-
priority: int | None = None,
117111
):
118112
super().__init__()
119113
if label and len(str(label)) > 80:
@@ -126,14 +120,11 @@ def __init__(
126120
raise TypeError("cannot mix both url and sku_id with Button")
127121
if custom_id is not None and sku_id is not None:
128122
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")
131123

132124
if not isinstance(custom_id, str) and custom_id is not None:
133125
raise TypeError(
134126
f"expected custom_id to be str, not {custom_id.__class__.__name__}"
135127
)
136-
self.priority: int | None = priority
137128

138129
self._provided_custom_id = custom_id is not None
139130
if url is None and custom_id is None and sku_id is None:
@@ -303,7 +294,6 @@ def button(
303294
emoji: str | GuildEmoji | AppEmoji | PartialEmoji | None = None,
304295
row: int | None = None,
305296
id: int | None = None,
306-
priority: int | None = None,
307297
) -> Callable[[ItemCallbackType[Button[V]]], Button[V]]:
308298
"""A decorator that attaches a button to a component.
309299
@@ -342,11 +332,6 @@ def button(
342332
.. warning::
343333
344334
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.
350335
"""
351336

352337
def decorator(func: ItemCallbackType) -> ItemCallbackType:
@@ -363,7 +348,6 @@ def decorator(func: ItemCallbackType) -> ItemCallbackType:
363348
"emoji": emoji,
364349
"row": row,
365350
"id": id,
366-
"priority": priority,
367351
}
368352
return func
369353

0 commit comments

Comments
 (0)