|
@ -57,11 +57,6 @@ class Section(Item[V]): |
|
|
The section accessory. |
|
|
The section accessory. |
|
|
id: Optional[:class:`int`] |
|
|
id: Optional[:class:`int`] |
|
|
The ID of this component. This must be unique across the view. |
|
|
The ID of this component. This must be unique across the view. |
|
|
|
|
|
|
|
|
Attributes |
|
|
|
|
|
---------- |
|
|
|
|
|
accessory: :class:`Item` |
|
|
|
|
|
The section accessory. |
|
|
|
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
__item_repr_attributes__ = ( |
|
|
__item_repr_attributes__ = ( |
|
@ -72,7 +67,7 @@ class Section(Item[V]): |
|
|
|
|
|
|
|
|
__slots__ = ( |
|
|
__slots__ = ( |
|
|
'_children', |
|
|
'_children', |
|
|
'accessory', |
|
|
'_accessory', |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
def __init__( |
|
|
def __init__( |
|
@ -83,13 +78,11 @@ class Section(Item[V]): |
|
|
) -> None: |
|
|
) -> None: |
|
|
super().__init__() |
|
|
super().__init__() |
|
|
self._children: List[Item[V]] = [] |
|
|
self._children: List[Item[V]] = [] |
|
|
if children: |
|
|
for child in children: |
|
|
if len(children) > 3: |
|
|
self.add_item(child) |
|
|
raise ValueError('maximum number of children exceeded') |
|
|
|
|
|
self._children.extend( |
|
|
accessory._parent = self |
|
|
[c if isinstance(c, Item) else TextDisplay(c) for c in children], |
|
|
self._accessory: Item[V] = accessory |
|
|
) |
|
|
|
|
|
self.accessory: Item[V] = accessory |
|
|
|
|
|
self.id = id |
|
|
self.id = id |
|
|
|
|
|
|
|
|
def __repr__(self) -> str: |
|
|
def __repr__(self) -> str: |
|
@ -108,6 +101,19 @@ class Section(Item[V]): |
|
|
def width(self): |
|
|
def width(self): |
|
|
return 5 |
|
|
return 5 |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
|
def accessory(self) -> Item[V]: |
|
|
|
|
|
""":class:`Item`: The section's accessory.""" |
|
|
|
|
|
return self._accessory |
|
|
|
|
|
|
|
|
|
|
|
@accessory.setter |
|
|
|
|
|
def accessory(self, value: Item[V]) -> None: |
|
|
|
|
|
if not isinstance(value, Item): |
|
|
|
|
|
raise TypeError(f'Expected an Item, got {value.__class__.__name__!r} instead') |
|
|
|
|
|
|
|
|
|
|
|
value._parent = self |
|
|
|
|
|
self._accessory = value |
|
|
|
|
|
|
|
|
def _is_v2(self) -> bool: |
|
|
def _is_v2(self) -> bool: |
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|