Browse Source

chore: Remove ValueError on Container.add_item

pull/10166/head
DA-344 3 weeks ago
parent
commit
cf08c0e78f
  1. 6
      discord/ui/container.py
  2. 4
      discord/ui/view.py

6
discord/ui/container.py

@ -340,13 +340,7 @@ class Container(Item[V]):
------ ------
TypeError TypeError
An :class:`Item` was not passed. An :class:`Item` was not passed.
ValueError
Maximum number of children has been exceeded (10).
""" """
if len(self._children) >= 10:
raise ValueError('maximum number of children exceeded')
if not isinstance(item, Item): if not isinstance(item, Item):
raise TypeError(f'expected Item not {item.__class__.__name__}') raise TypeError(f'expected Item not {item.__class__.__name__}')

4
discord/ui/view.py

@ -337,7 +337,7 @@ class BaseView:
TypeError TypeError
An :class:`Item` was not passed. An :class:`Item` was not passed.
ValueError ValueError
Maximum number of children has been exceeded (25), the Maximum number of children has been exceeded, the
row the item is trying to be added to is full or the item row the item is trying to be added to is full or the item
you tried to add is not allowed in this View. you tried to add is not allowed in this View.
""" """
@ -803,7 +803,7 @@ class LayoutView(BaseView):
def add_item(self, item: Item[Any]) -> Self: def add_item(self, item: Item[Any]) -> Self:
if self.__total_children >= 40: if self.__total_children >= 40:
raise ValueError('maximum number of children exceeded') raise ValueError('maximum number of children exceeded (40)')
super().add_item(item) super().add_item(item)
return self return self

Loading…
Cancel
Save