Skip to content

Commit 605beb5

Browse files
authored
v2 view parsing
1 parent f643b5e commit 605beb5

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

discord/ui/view.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,22 @@ def to_components(self) -> list[dict[str, Any]]:
226226
def key(item: Item) -> int:
227227
return item._rendered_row or 0
228228

229-
children = sorted(self.children, key=key)
230-
components: list[dict[str, Any]] = []
231-
for _, group in groupby(children, key=key):
232-
children = [item.to_component_dict() for item in group]
233-
if not children:
234-
continue
235-
236-
components.append(
237-
{
238-
"type": 1,
239-
"components": children,
240-
}
241-
)
229+
if self.is_v2():
230+
components = [item.to_component_dict() for item in self.children]
231+
else:
232+
children = sorted(self.children, key=key)
233+
components: list[dict[str, Any]] = []
234+
for _, group in groupby(children, key=key):
235+
children = [item.to_component_dict() for item in group]
236+
if not children:
237+
continue
238+
239+
components.append(
240+
{
241+
"type": 1,
242+
"components": children,
243+
}
244+
)
242245

243246
return components
244247

0 commit comments

Comments
 (0)