Browse Source

Return embed from clear_fields and remove_field

pull/7998/head
Jonah Lawrence 3 years ago
committed by GitHub
parent
commit
1451074d66
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      discord/embeds.py

23
discord/embeds.py

@ -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…
Cancel
Save