Skip to content

Commit bdb6d21

Browse files
authored
maybe?
1 parent e32fdad commit bdb6d21

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

discord/ui/action_row.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,21 @@ def _add_component_from_item(self, item: Item):
9191

9292
def _set_components(self, items: list[Item]):
9393
self._underlying.components.clear()
94-
if not any(isinstance(b, Select) for b in self.children):
94+
for item in items:
95+
self._add_component_from_item(item)
96+
97+
def _reorder(self):
98+
items = self.children
99+
if not any([isinstance(b, Select) for b in self.children]):
95100
a, b = [], []
96101
for i in items:
97102
if i.priority is None:
98103
b.append(i)
99104
else:
100105
a.append(i)
101-
items = sorted(a, key=lambda b: b.priority) + b
102-
for item in items:
103-
self._add_component_from_item(item)
106+
items = sorted(a, key=lambda c: c.priority) + b
107+
self.children = items
108+
self._set_components(items)
104109

105110
def add_item(self, item: Item) -> Self:
106111
"""Adds an item to the action row.
@@ -350,7 +355,7 @@ def walk_items(self) -> Iterator[Item]:
350355
yield from self.children
351356

352357
def to_component_dict(self) -> ActionRowPayload:
353-
self._set_components(self.children)
358+
self._reorder()
354359
return self._underlying.to_dict()
355360

356361
@classmethod

0 commit comments

Comments
 (0)