Browse Source

chore: Update container to also take in account section accessories

pull/10166/head
DA-344 3 months ago
parent
commit
810fe57283
  1. 8
      discord/ui/container.py
  2. 8
      discord/ui/section.py

8
discord/ui/container.py

@ -218,8 +218,12 @@ class Container(Item[V]):
pattern = item.__discord_ui_compiled_template__
dynamic_items[pattern] = item.__class__
elif item.is_dispatchable():
dispatch_info[(item.type.value, item.custom_id)] = item # type: ignore
is_fully_dynamic = False
if getattr(item, '__discord_ui_section__', False):
accessory = item.accessory # type: ignore
dispatch_info[(accessory.type.value, accessory.custom_id)] = accessory
else:
dispatch_info[(item.type.value, item.custom_id)] = item # type: ignore
is_fully_dynamic = False
return is_fully_dynamic
@classmethod

8
discord/ui/section.py

@ -64,6 +64,7 @@ class Section(Item[V]):
"""
__discord_ui_section__: ClassVar[bool] = True
__pending_view__: ClassVar[bool] = True
__slots__ = (
'_children',
@ -107,9 +108,10 @@ class Section(Item[V]):
# be accessory component callback, only called if accessory is
# dispatchable?
def is_dispatchable(self) -> bool:
if self.accessory:
return self.accessory.is_dispatchable()
return False
return self.accessory.is_dispatchable()
def _update_children_view(self, view) -> None:
self.accessory._view = view
def add_item(self, item: Union[str, Item[Any]]) -> Self:
"""Adds an item to this section.

Loading…
Cancel
Save