Skip to content

Commit 56df1a8

Browse files
authored
fix: add missed logic to Embed.insert_field_at (#951)
* refactor: add missed logic to ``Embed.insert_field_at`` * make name and value required * remove excepting indexerror
1 parent 5506f8d commit 56df1a8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

interactions/api/models/message.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ def clear_fields(self) -> None:
563563
self.fields = []
564564

565565
def insert_field_at(
566-
self, index: int, name: str = None, value: str = None, inline: Optional[bool] = False
566+
self, index: int, name: str, value: str, inline: Optional[bool] = False
567567
) -> None:
568568
"""
569569
Inserts a field in the embed at the specified index
@@ -578,6 +578,14 @@ def insert_field_at(
578578
:type inline?: Optional[bool]
579579
"""
580580

581+
try:
582+
fields = self.fields
583+
fields.insert(index, EmbedField(name=name, value=value, inline=inline))
584+
self.fields = fields
585+
586+
except AttributeError as e:
587+
raise AttributeError("No fields found in Embed") from e
588+
581589
def set_field_at(
582590
self, index: int, name: str, value: str, inline: Optional[bool] = False
583591
) -> None:

0 commit comments

Comments
 (0)