Merge pull request #41

* Fixed `TypeError`

* Handles `EmptyEmbed` inside setter instead of set_

* Remove return and setter docstring
This commit is contained in:
Ahmad Ansori Palembani 2021-09-03 02:46:56 +07:00 committed by GitHub
parent 0f6db99c59
commit f37be7961a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -404,7 +404,10 @@ class Embed:
return EmbedProxy(getattr(self, '_image', {})) # type: ignore return EmbedProxy(getattr(self, '_image', {})) # type: ignore
@image.setter @image.setter
def image(self: E, *, url: Any): def image(self: E, url: Any):
if url is EmptyEmbed:
del self._image
else:
self._image = { self._image = {
'url': str(url), 'url': str(url),
} }
@ -431,9 +434,6 @@ class Embed:
The source URL for the image. Only HTTP(S) is supported. The source URL for the image. Only HTTP(S) is supported.
""" """
if url is EmptyEmbed:
del self.image
else:
self.image = url self.image = url
return self return self
@ -454,16 +454,14 @@ class Embed:
return EmbedProxy(getattr(self, '_thumbnail', {})) # type: ignore return EmbedProxy(getattr(self, '_thumbnail', {})) # type: ignore
@thumbnail.setter @thumbnail.setter
def thumbnail(self: E, *, url: Any): def thumbnail(self: E, url: Any):
"""Sets the thumbnail for the embed content. if url is EmptyEmbed:
""" del self._thumbnail
else:
self._thumbnail = { self._thumbnail = {
'url': str(url), 'url': str(url),
} }
return
@thumbnail.deleter @thumbnail.deleter
def thumbnail(self): def thumbnail(self):
try: try:
@ -485,9 +483,7 @@ class Embed:
url: :class:`str` url: :class:`str`
The source URL for the thumbnail. Only HTTP(S) is supported. The source URL for the thumbnail. Only HTTP(S) is supported.
""" """
if url is EmptyEmbed:
del self.thumbnail
else:
self.thumbnail = url self.thumbnail = url
return self return self