Change View.children to be a property

This allows users to call remove_item in a loop. Likewise, it prevents
the footgun of doing children.append(...) which does not uphold the
invariants with the weight system.
This commit is contained in:
Rapptz
2022-04-03 19:23:57 -04:00
parent d5d9a532b2
commit 1458251736
2 changed files with 19 additions and 21 deletions

View File

@ -89,8 +89,6 @@ class Modal(View):
------------
title: :class:`str`
The title of the modal.
children: List[:class:`Item`]
The list of children attached to this view.
custom_id: :class:`str`
The ID of the modal that gets received during an interaction.
"""
@ -172,7 +170,7 @@ class Modal(View):
if component['type'] == 1:
self._refresh(component['components'])
else:
item = find(lambda i: i.custom_id == component['custom_id'], self.children) # type: ignore
item = find(lambda i: i.custom_id == component['custom_id'], self._children) # type: ignore
if item is None:
_log.debug("Modal interaction referencing unknown item custom_id %s. Discarding", component['custom_id'])
continue