Add an insert_field_at method for the embed class
This commit is contained in:
parent
2fd589874f
commit
f2c7b2e6d8
@ -422,6 +422,39 @@ class Embed:
|
||||
self._fields = [field]
|
||||
|
||||
return self
|
||||
|
||||
def insert_field_at(self, index, *, name, value, inline=True):
|
||||
"""Inserts a field before a specified index to the embed.
|
||||
|
||||
This function returns the class instance to allow for fluent-style
|
||||
chaining.
|
||||
|
||||
.. versionadded:: 1.2.0
|
||||
|
||||
Parameters
|
||||
-----------
|
||||
index: :class:`int`
|
||||
The index of where to insert the field.
|
||||
name: :class:`str`
|
||||
The name of the field.
|
||||
value: :class:`str`
|
||||
The value of the field.
|
||||
inline: :class:`bool`
|
||||
Whether the field should be displayed inline.
|
||||
"""
|
||||
|
||||
field = {
|
||||
'inline': inline,
|
||||
'name': str(name),
|
||||
'value': str(value)
|
||||
}
|
||||
|
||||
try:
|
||||
self._fields.insert(index, field)
|
||||
except AttributeError:
|
||||
self._fields = [field]
|
||||
|
||||
return self
|
||||
|
||||
def clear_fields(self):
|
||||
"""Removes all fields from this embed."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user