@@ -902,11 +902,195 @@ def __init__(self, **kwargs):
902902 if self .footer :
903903 self ._json .update ({"footer" : self .footer ._json })
904904
905- if self .video :
906- self ._json .update ({"video" : self .video ._json })
905+ def add_field (self , name : str , value : str , inline : Optional [bool ] = False ) -> None :
906+ """
907+ Adds a field to the embed
908+
909+ :param name: The name of the field
910+ :type name: str
911+ :param value: The value of the field
912+ :type value: str
913+ :param inline?: if the field is in the same line as the previous one
914+ :type inline?: Optional[bool]
915+ """
916+
917+ if self .fields is None :
918+ self .fields = []
919+
920+ self .fields .append (EmbedField (name = name , value = value , inline = inline ))
921+ self ._json .update ({"fields" : [field ._json for field in self .fields ]})
922+
923+ def clear_fields (self ) -> None :
924+ """
925+ Clears all the fields of the embed
926+ """
927+
928+ self .fields = []
929+ self ._json .update ({"fields" : []})
930+
931+ def insert_field_at (
932+ self , index : int , name : str = None , value : str = None , inline : Optional [bool ] = False
933+ ) -> None :
934+ """
935+ Inserts a field in the embed at the specified index
936+
937+ :param index: The new field's index
938+ :type index: int
939+ :param name: The name of the field
940+ :type name: str
941+ :param value: The value of the field
942+ :type value: str
943+ :param inline?: if the field is in the same line as the previous one
944+ :type inline?: Optional[bool]
945+ """
946+
947+ try :
948+ self .fields .insert (index , EmbedField (name = name , value = value , inline = inline ))
949+
950+ except AttributeError :
951+ self .fields = [EmbedField (name = name , value = value , inline = inline )]
952+
953+ self ._json .update ({"fields" : [field ._json for field in self .fields ]})
954+
955+ def set_field_at (
956+ self , index : int , name : str , value : str , inline : Optional [bool ] = False
957+ ) -> None :
958+ """
959+ Overwrites the field in the embed at the specified index
960+
961+ :param index: The new field's index
962+ :type index: int
963+ :param name: The name of the field
964+ :type name: str
965+ :param value: The value of the field
966+ :type value: str
967+ :param inline?: if the field is in the same line as the previous one
968+ :type inline?: Optional[bool]
969+ """
970+
971+ try :
972+ self .fields [index ] = EmbedField (name = name , value = value , inline = inline )
973+ self ._json .update ({"fields" : [field ._json for field in self .fields ]})
974+
975+ except AttributeError :
976+ raise AttributeError ("No fields found in Embed" )
977+
978+ except IndexError :
979+ raise IndexError ("No fields at this index" )
980+
981+ def remove_field (self , index : int ) -> None :
982+ """
983+ Remove field at the specified index
984+
985+ :param index: The new field's index
986+ :type index: int
987+ """
988+
989+ try :
990+ self .fields .pop (index )
991+ self ._json .update ({"fields" : [field ._json for field in self .fields ]})
992+
993+ except AttributeError :
994+ raise AttributeError ("No fields found in Embed" )
995+
996+ except IndexError :
997+ raise IndexError ("Field not Found at index" )
998+
999+ def remove_author (self ) -> None :
1000+ """
1001+ Removes the embed's author
1002+ """
1003+
1004+ try :
1005+ del self .author
1006+ self ._json .update ({"author" : None })
1007+ except AttributeError :
1008+ pass
1009+
1010+ def set_author (
1011+ self ,
1012+ name : str ,
1013+ url : Optional [str ] = None ,
1014+ icon_url : Optional [str ] = None ,
1015+ proxy_icon_url : Optional [str ] = None ,
1016+ ) -> None :
1017+ """
1018+ Sets the embed's author
1019+
1020+ :param name: The name of the author
1021+ :type name: str
1022+ :param url?: Url of author
1023+ :type url?: Optional[str]
1024+ :param icon_url?: Url of author icon (only supports http(s) and attachments)
1025+ :type icon_url?: Optional[str]
1026+ :param proxy_icon_url?: A proxied url of author icon
1027+ :type proxy_icon_url?: Optional[str]
1028+ """
1029+
1030+ self .author = EmbedAuthor (
1031+ name = name , url = url , icon_url = icon_url , proxy_icon_url = proxy_icon_url
1032+ )
1033+ self ._json .update ({"author" : self .author ._json })
9071034
908- if self .image :
909- self ._json .update ({"image" : self .image ._json })
1035+ def set_footer (
1036+ self , text : str , icon_url : Optional [str ] = None , proxy_icon_url : Optional [str ] = None
1037+ ) -> None :
1038+ """
1039+ Sets the embed's footer
1040+
1041+ :param text: The text of the footer
1042+ :type text: str
1043+ :param icon_url?: Url of footer icon (only supports http(s) and attachments)
1044+ :type icon_url?: Optional[str]
1045+ :param proxy_icon_url?: A proxied url of footer icon
1046+ :type proxy_icon_url?: Optional[str]
1047+ """
1048+
1049+ self .footer = EmbedFooter (text = text , icon_url = icon_url , proxy_icon_url = proxy_icon_url )
1050+ self ._json .update ({"footer" : self .footer ._json })
1051+
1052+ def set_image (
1053+ self ,
1054+ url : str ,
1055+ proxy_url : Optional [str ] = None ,
1056+ height : Optional [int ] = None ,
1057+ width : Optional [int ] = None ,
1058+ ) -> None :
1059+ """
1060+ Sets the embed's image
1061+
1062+ :param url: Url of the image
1063+ :type url: str
1064+ :param proxy_url?: A proxied url of the image
1065+ :type proxy_url?: Optional[str]
1066+ :param height?: The image's height
1067+ :type height?: Optional[int]
1068+ :param width?: The image's width
1069+ :type width?: Optional[int]
1070+ """
1071+
1072+ self .image = EmbedImageStruct (url = url , proxy_url = proxy_url , height = height , width = width )
1073+ self ._json .update ({"image" : self .image ._json })
1074+
1075+ def set_thumbnail (
1076+ self ,
1077+ url : str ,
1078+ proxy_url : Optional [str ] = None ,
1079+ height : int = None ,
1080+ width : Optional [str ] = None ,
1081+ ) -> None :
1082+ """
1083+ Sets the embed's thumbnail
1084+
1085+ :param url: Url of the thumbnail
1086+ :type url: str
1087+ :param proxy_url?: A proxied url of the thumbnail
1088+ :type proxy_url?: Optional[str]
1089+ :param height?: The thumbnail's height
1090+ :type height?: Optional[int]
1091+ :param width?: The thumbnail's width
1092+ :type width?: Optional[int]
1093+ """
9101094
911- if self .thumbnail :
912- self ._json .update ({"thumbnail" : self .thumbnail ._json })
1095+ self .thumbnail = EmbedImageStruct ( url = url , proxy_url = proxy_url , height = height , width = width )
1096+ self ._json .update ({"thumbnail" : self .thumbnail ._json })
0 commit comments