diff --git a/litecord/embed/schemas.py b/litecord/embed/schemas.py index 61452c6..63d8246 100644 --- a/litecord/embed/schemas.py +++ b/litecord/embed/schemas.py @@ -31,16 +31,18 @@ class EmbedURL: if parsed.scheme not in ('http', 'https', 'attachment'): raise ValueError('Invalid URL scheme') + self.scheme = parsed.scheme self.raw_url = url self.parsed = parsed @property - def url(self): - """Return the URL.""" + def url(self) -> str: + """Return the unparsed URL.""" return urllib.parse.urlunparse(self.parsed) @property - def to_json(self): + def to_json(self) -> str: + """'json' version of the url.""" return self.url diff --git a/litecord/schemas.py b/litecord/schemas.py index fd1553e..980a7ff 100644 --- a/litecord/schemas.py +++ b/litecord/schemas.py @@ -31,7 +31,7 @@ from .enums import ( MessageNotifications, ChannelType, VerificationLevel ) -from litecord.embed.schemas import EMBED_OBJECT +from litecord.embed.schemas import EMBED_OBJECT, EmbedURL log = Logger(__name__) @@ -710,10 +710,8 @@ WEBHOOK_MESSAGE_CREATE = { 'minlength': 2, 'maxlength': 32, 'required': False }, - # TODO: url type, or something... 'avatar_url': { - # 'type': 'url', 'required': False - 'type': 'string', 'required': False + 'coerce': EmbedURL, 'required': False }, 'embeds': {