mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-19 15:36:02 +00:00
Return embed from clear_fields and remove_field
This commit is contained in:
parent
7b65be9d25
commit
1451074d66
@ -602,24 +602,39 @@ class Embed:
|
||||
|
||||
return self
|
||||
|
||||
def clear_fields(self) -> None:
|
||||
"""Removes all fields from this embed."""
|
||||
def clear_fields(self) -> Self:
|
||||
"""Removes all fields from this embed.
|
||||
|
||||
This function returns the class instance to allow for fluent-style
|
||||
chaining.
|
||||
|
||||
.. versionchanged:: 2.0
|
||||
This function now returns the class instance.
|
||||
"""
|
||||
try:
|
||||
self._fields.clear()
|
||||
except AttributeError:
|
||||
self._fields = []
|
||||
|
||||
def remove_field(self, index: int) -> None:
|
||||
return self
|
||||
|
||||
def remove_field(self, index: int) -> Self:
|
||||
"""Removes a field at a specified index.
|
||||
|
||||
If the index is invalid or out of bounds then the error is
|
||||
silently swallowed.
|
||||
|
||||
This function returns the class instance to allow for fluent-style
|
||||
chaining.
|
||||
|
||||
.. note::
|
||||
|
||||
When deleting a field by index, the index of the other fields
|
||||
shift to fill the gap just like a regular list.
|
||||
|
||||
.. versionchanged:: 2.0
|
||||
This function now returns the class instance.
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
index: :class:`int`
|
||||
@ -630,6 +645,8 @@ class Embed:
|
||||
except (AttributeError, IndexError):
|
||||
pass
|
||||
|
||||
return self
|
||||
|
||||
def set_field_at(self, index: int, *, name: Any, value: Any, inline: bool = True) -> Self:
|
||||
"""Modifies a field to the embed object.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user