mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-06 09:56:09 +00:00
Implement Embed.__eq__ and EmbedProxy.__eq__
This commit is contained in:
@ -51,6 +51,9 @@ class EmbedProxy:
|
||||
def __getattr__(self, attr: str) -> None:
|
||||
return None
|
||||
|
||||
def __eq__(self, other: object) -> bool:
|
||||
return isinstance(other, EmbedProxy) and self.__dict__ == other.__dict__
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing_extensions import Self
|
||||
@ -106,6 +109,12 @@ class Embed:
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
.. describe:: x == y
|
||||
|
||||
Checks if two embeds are equal.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
For ease of use, all parameters that expect a :class:`str` are implicitly
|
||||
casted to :class:`str` for you.
|
||||
|
||||
@ -281,6 +290,23 @@ class Embed:
|
||||
)
|
||||
)
|
||||
|
||||
def __eq__(self, other: Embed) -> bool:
|
||||
return isinstance(other, Embed) and (
|
||||
self.type == other.type
|
||||
and self.title == other.title
|
||||
and self.url == other.url
|
||||
and self.description == other.description
|
||||
and self.colour == other.colour
|
||||
and self.fields == other.fields
|
||||
and self.timestamp == other.timestamp
|
||||
and self.author == other.author
|
||||
and self.thumbnail == other.thumbnail
|
||||
and self.footer == other.footer
|
||||
and self.image == other.image
|
||||
and self.provider == other.provider
|
||||
and self.video == other.video
|
||||
)
|
||||
|
||||
@property
|
||||
def colour(self) -> Optional[Colour]:
|
||||
return getattr(self, '_colour', None)
|
||||
|
Reference in New Issue
Block a user