Skip to content

Commit

Permalink
feat: add supporr for Item object in exclusions
Browse files Browse the repository at this point in the history
  • Loading branch information
27Saumya authored Apr 12, 2022
1 parent be46a6e commit cbef3fc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions discord/ui/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,18 +467,20 @@ async def wait(self) -> bool:
"""
return await self.__stopped

def disable_all_items(self, *, exclusions: Optional[List[int]]) -> None:
def disable_all_items(self, *, exclusions: Optional[List[Union[int, View.Item]]) -> None:
"""
Disables all items in the view.
Parameters
-----------
exclusions: Optional[List[:class:`int`]]
A list of item indexes in `self.children` to not disable from the view.
exclusions: Optional[List[Union[:class:`int`, :class:`View.Item`]]]
A list of items or indexes in `self.children` to not disable from the view.
"""
for i in range(len(self.children)):
if exclusions is None or i not in exclusions:
for i in exclusions:
if isinstance(i, int):
self.children[i].disabled = True
elif isinstance(i, discord.ui.Item):
i.disabled = True


class ViewStore:
Expand Down

0 comments on commit cbef3fc

Please sign in to comment.