mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-01 07:40:07 +00:00
Change View child mutators to be fluent-style methods
This commit is contained in:
parent
5d6905a1bc
commit
94f4da9248
@ -252,9 +252,10 @@ class View:
|
|||||||
view.add_item(_component_to_item(component))
|
view.add_item(_component_to_item(component))
|
||||||
return view
|
return view
|
||||||
|
|
||||||
def add_item(self, item: Item[Any]) -> None:
|
def add_item(self, item: Item[Any]) -> Self:
|
||||||
"""Adds an item to the view.
|
"""Adds an item to the view.
|
||||||
|
This function returns the class instance to allow for fluent-style
|
||||||
|
chaining.
|
||||||
Parameters
|
Parameters
|
||||||
-----------
|
-----------
|
||||||
item: :class:`Item`
|
item: :class:`Item`
|
||||||
@ -279,9 +280,12 @@ class View:
|
|||||||
|
|
||||||
item._view = self
|
item._view = self
|
||||||
self.children.append(item)
|
self.children.append(item)
|
||||||
|
return self
|
||||||
|
|
||||||
def remove_item(self, item: Item[Any]) -> None:
|
def remove_item(self, item: Item[Any]) -> Self:
|
||||||
"""Removes an item from the view.
|
"""Removes an item from the view.
|
||||||
|
This function returns the class instance to allow for fluent-style
|
||||||
|
chaining.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
-----------
|
-----------
|
||||||
@ -295,11 +299,16 @@ class View:
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.__weights.remove_item(item)
|
self.__weights.remove_item(item)
|
||||||
|
return self
|
||||||
|
|
||||||
def clear_items(self) -> None:
|
def clear_items(self) -> Self:
|
||||||
"""Removes all items from the view."""
|
"""Removes all items from the view.
|
||||||
|
This function returns the class instance to allow for fluent-style
|
||||||
|
chaining.
|
||||||
|
"""
|
||||||
self.children.clear()
|
self.children.clear()
|
||||||
self.__weights.clear()
|
self.__weights.clear()
|
||||||
|
return self
|
||||||
|
|
||||||
async def interaction_check(self, interaction: Interaction) -> bool:
|
async def interaction_check(self, interaction: Interaction) -> bool:
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user