Browse Source

Add Embed.__bool__

Fixes #6661
pull/6664/head
Rapptz 4 years ago
parent
commit
ed1341012b
  1. 22
      discord/embeds.py

22
discord/embeds.py

@ -63,6 +63,12 @@ class Embed:
Returns the total size of the embed. Returns the total size of the embed.
Useful for checking if it's within the 6000 character limit. Useful for checking if it's within the 6000 character limit.
.. describe:: bool(b)
Returns whether the embed has any data set.
.. versionadded:: 2.0
Certain properties return an ``EmbedProxy``, a type Certain properties return an ``EmbedProxy``, a type
that acts similar to a regular :class:`dict` except using dotted access, that acts similar to a regular :class:`dict` except using dotted access,
e.g. ``embed.author.icon_url``. If the attribute e.g. ``embed.author.icon_url``. If the attribute
@ -217,6 +223,22 @@ class Embed:
return total return total
def __bool__(self):
return any((
self.title,
self.url,
self.description,
self.colour,
self.fields,
self.timestamp,
self.author,
self.thumbnail,
self.footer,
self.image,
self.provider,
self.video,
))
@property @property
def colour(self): def colour(self):
return getattr(self, '_colour', EmptyEmbed) return getattr(self, '_colour', EmptyEmbed)

Loading…
Cancel
Save