Skip to content

Commit

Permalink
Add disable_all_items in View (#1199)
Browse files Browse the repository at this point in the history
* Add `disable_all_items` in `View`

* Update view.py

* add suggested changes

Co-authored-by: Middledot <78228142+Middledot@users.noreply.github.com>

* fix: add suggested changes

Co-authored-by: krittick <ben@krittick.net>

* feat: add supporr for Item object in `exclusions`

* fix: typehint

* fix: parenthesis

* feat: add more checks in `View.disable_all_items`

* fix: typehint

* feat: remove `int` from `exclusions`

* fix: code fixes

* Update discord/ui/view.py

Co-authored-by: plun1331 <49261529+plun1331@users.noreply.github.com>

* fix: `exclusions` param -> optional

* Update discord/ui/view.py

Co-authored-by: plun1331 <49261529+plun1331@users.noreply.github.com>

Co-authored-by: Middledot <78228142+Middledot@users.noreply.github.com>
Co-authored-by: krittick <ben@krittick.net>
Co-authored-by: Lala Sabathil <lala@pycord.dev>
Co-authored-by: Lala Sabathil <aiko@aitsys.dev>
Co-authored-by: plun1331 <49261529+plun1331@users.noreply.github.com>
  • Loading branch information
6 people authored Apr 29, 2022
1 parent 23e72dd commit fe5803f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions discord/ui/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,19 @@ async def wait(self) -> bool:
"""
return await self.__stopped

def disable_all_items(self, *, exclusions: Optional[List[Item]] = None) -> None:
"""
Disables all items in the view.
Parameters
-----------
exclusions: Optional[List[:class:`ui.Item`]]
A list of items in `self.children` to not disable from the view.
"""
for child in self.children:
if exclusions is None or child not in exclusions:
child.disabled = True


class ViewStore:
def __init__(self, state: ConnectionState):
Expand Down

0 comments on commit fe5803f

Please sign in to comment.