|
|
@ -36,6 +36,9 @@ class _EmptyEmbed: |
|
|
|
def __repr__(self): |
|
|
|
return 'Embed.Empty' |
|
|
|
|
|
|
|
def __len__(self): |
|
|
|
return 0 |
|
|
|
|
|
|
|
EmptyEmbed = _EmptyEmbed() |
|
|
|
|
|
|
|
class EmbedProxy: |
|
|
@ -54,6 +57,13 @@ class EmbedProxy: |
|
|
|
class Embed: |
|
|
|
"""Represents a Discord embed. |
|
|
|
|
|
|
|
.. container:: operations |
|
|
|
|
|
|
|
.. describe:: len(x) |
|
|
|
|
|
|
|
Returns the total size of the embed. |
|
|
|
Useful for checking if it's within the 6000 character limit. |
|
|
|
|
|
|
|
The following attributes can be set during creation |
|
|
|
of the object: |
|
|
|
|
|
|
@ -159,6 +169,27 @@ class Embed: |
|
|
|
|
|
|
|
return self |
|
|
|
|
|
|
|
def __len__(self): |
|
|
|
total = len(self.title) + len(self.description) |
|
|
|
for field in getattr(self, '_fields', []): |
|
|
|
total += len(field['name']) + len(field['value']) |
|
|
|
|
|
|
|
try: |
|
|
|
footer = self._footer |
|
|
|
except AttributeError: |
|
|
|
pass |
|
|
|
else: |
|
|
|
total += len(footer['text']) |
|
|
|
|
|
|
|
try: |
|
|
|
author = self._author |
|
|
|
except AttributeError: |
|
|
|
pass |
|
|
|
else: |
|
|
|
total += len(author['name']) |
|
|
|
|
|
|
|
return total |
|
|
|
|
|
|
|
@property |
|
|
|
def colour(self): |
|
|
|
return getattr(self, '_colour', EmptyEmbed) |
|
|
|