def add_field(self, *, name: str, value: str, inline: bool = True) -> 'Embed': """ Adds a field to the embed. :param name: The field name. :param value: The field value. :param inline: Is this field inline? :return: The Embed object. """ if isinstance(name, str) and len(name) == 0: raise ValueError("Name must not be empty") if isinstance(value, str) and len(value) == 0: raise ValueError("Value must not be empty") self._fields.append( attrdict({ "name": str(name), "value": str(value), "inline": inline })) return self
def set_thumbnail(self, *, url: str) -> 'Embed': """ Sets the thumbnail image of this embed. :param url: The image URL of this thumbnail. :return: The Embed object. """ self.thumbnail = attrdict() self.thumbnail.url = url return self
def set_footer(self, *, text: str = None, icon_url: str = None) -> 'Embed': """ Sets the footer of this embed. :param text: The footer text of this embed. :param icon_url: The icon URL for the footer. :return: The Embed object. """ self.footer = attrdict() if text: self.footer.text = text if icon_url: self.footer.icon_url = icon_url return self
def set_image(self, *, image_url: str) -> 'Embed': """ Sets the image of this embed. :param image_url: The image URL of this embed. :return: The Embed object. """ self.image = attrdict() if not image_url.startswith("http") or image_url.startswith( "attachment://"): raise ValueError("Image URLs must start with http[s]") if image_url: self.image.image_url = image_url return self
def set_author(self, *, name: str = None, url: str = None) -> 'Embed': """ Sets the author of this embed. :param name: The name of the author. :param url: The URL of the author. :return: The Embed object. """ self.author = attrdict() if name: self.author.name = name if url: self.author.url = url return self
def make_attrdict(key: str) -> attrdict: if key not in kwargs: return attrdict() return attrdict(**kwargs[key])