aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-04-07 00:00:44 -0400
committerRapptz <[email protected]>2021-04-07 00:01:57 -0400
commited1341012b4c6a893a9f48001af465decd634133 (patch)
tree9714a2134b81a0c6017ac856ca70cf5f77b10b63
parentRevert "Remove unused group functionality" (diff)
downloaddiscord.py-ed1341012b4c6a893a9f48001af465decd634133.tar.xz
discord.py-ed1341012b4c6a893a9f48001af465decd634133.zip
Add Embed.__bool__
Fixes #6661
-rw-r--r--discord/embeds.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/discord/embeds.py b/discord/embeds.py
index 59278c97..4ccf4cf9 100644
--- a/discord/embeds.py
+++ b/discord/embeds.py
@@ -63,6 +63,12 @@ class Embed:
Returns the total size of the embed.
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
that acts similar to a regular :class:`dict` except using dotted access,
e.g. ``embed.author.icon_url``. If the attribute
@@ -217,6 +223,22 @@ class Embed:
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
def colour(self):
return getattr(self, '_colour', EmptyEmbed)