Browse Source

Make Container._init_children more similar to BaseView._init_children

pull/10166/head
DA344 2 months ago
committed by GitHub
parent
commit
eb2996d91e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 16
      discord/ui/container.py

16
discord/ui/container.py

@ -175,23 +175,15 @@ class Container(Item[V]):
for name, raw in self.__container_children_items__.items(): for name, raw in self.__container_children_items__.items():
if isinstance(raw, Item): if isinstance(raw, Item):
if getattr(raw, '__discord_ui_action_row__', False): item = copy.deepcopy(raw)
item = copy.deepcopy(raw) item._parent = self
# we need to deepcopy this object and set it later to prevent if getattr(item, '__discord_ui_action_row__', False):
# errors reported on the bikeshedding post
item._parent = self
if item.is_dispatchable(): if item.is_dispatchable():
self.__dispatchable.extend(item._children) # type: ignore self.__dispatchable.extend(item._children) # type: ignore
if getattr(raw, '__discord_ui_section__', False): if getattr(item, '__discord_ui_section__', False):
item = copy.copy(raw)
if item.accessory.is_dispatchable(): # type: ignore if item.accessory.is_dispatchable(): # type: ignore
item.accessory = copy.deepcopy(item.accessory) # type: ignore
if item.accessory._provided_custom_id is False: # type: ignore if item.accessory._provided_custom_id is False: # type: ignore
item.accessory.custom_id = os.urandom(16).hex() # type: ignore item.accessory.custom_id = os.urandom(16).hex() # type: ignore
else:
item = copy.copy(raw)
if getattr(item, '__discord_ui_section__', False) and item.accessory.is_dispatchable(): # type: ignore if getattr(item, '__discord_ui_section__', False) and item.accessory.is_dispatchable(): # type: ignore
self.__dispatchable.append(item.accessory) # type: ignore self.__dispatchable.append(item.accessory) # type: ignore

Loading…
Cancel
Save