diff options
| author | Rapptz <[email protected]> | 2021-05-28 00:30:31 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2021-05-28 00:53:28 -0400 |
| commit | 97f308d2198de1162a28429ff9f564365ba46f59 (patch) | |
| tree | 1c859202a66f527677e3b49cd993ab90497477a9 /discord | |
| parent | Add View.interaction_check for interaction pre-conditions (diff) | |
| download | discord.py-97f308d2198de1162a28429ff9f564365ba46f59.tar.xz discord.py-97f308d2198de1162a28429ff9f564365ba46f59.zip | |
Add View.remove_item and View.clear_items
Diffstat (limited to 'discord')
| -rw-r--r-- | discord/ui/view.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/discord/ui/view.py b/discord/ui/view.py index 773d1899..b5cf2f0d 100644 --- a/discord/ui/view.py +++ b/discord/ui/view.py @@ -179,6 +179,24 @@ class View: item._view = self self.children.append(item) + def remove_item(self, item: Item) -> None: + """Removes an item from the view. + + Parameters + ----------- + item: :class:`Item` + The item to remove from the view. + """ + + try: + self.children.remove(item) + except ValueError: + pass + + def clear_items(self) -> None: + """Removes all items from the view.""" + self.children.clear() + async def interaction_check(self, interaction: Interaction) -> bool: """|coro| |