mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-21 08:17:47 +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))
|
||||
return view
|
||||
|
||||
def add_item(self, item: Item[Any]) -> None:
|
||||
def add_item(self, item: Item[Any]) -> Self:
|
||||
"""Adds an item to the view.
|
||||
|
||||
This function returns the class instance to allow for fluent-style
|
||||
chaining.
|
||||
Parameters
|
||||
-----------
|
||||
item: :class:`Item`
|
||||
@ -279,9 +280,12 @@ class View:
|
||||
|
||||
item._view = self
|
||||
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.
|
||||
This function returns the class instance to allow for fluent-style
|
||||
chaining.
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
@ -295,11 +299,16 @@ class View:
|
||||
pass
|
||||
else:
|
||||
self.__weights.remove_item(item)
|
||||
return self
|
||||
|
||||
def clear_items(self) -> None:
|
||||
"""Removes all items from the view."""
|
||||
def clear_items(self) -> Self:
|
||||
"""Removes all items from the view.
|
||||
This function returns the class instance to allow for fluent-style
|
||||
chaining.
|
||||
"""
|
||||
self.children.clear()
|
||||
self.__weights.clear()
|
||||
return self
|
||||
|
||||
async def interaction_check(self, interaction: Interaction) -> bool:
|
||||
"""|coro|
|
||||
|
Loading…
x
Reference in New Issue
Block a user