Skip to content

Fix bug in embeds EmbedMediaProxy which results in the boolean value of an Embed to always be truthy #10154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions discord/embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@
super().__init__(layer)
self._flags = self.__dict__.pop('flags', 0)

def __bool__(self) -> bool:
# This is a nasty check to see if we only have the `_flags` attribute which is created regardless in init.
# Had we had any of the other items, like image/video data this would be >1 and therefor
# would not be "empty".
return len(self.__dict__) > 1

@property
def flags(self) -> AttachmentFlags:
return AttachmentFlags._from_value(self._flags or 0)


if TYPE_CHECKING:
from typing_extensions import Self

Check warning on line 76 in discord/embeds.py

View workflow job for this annotation

GitHub Actions / check 3.x

Import "typing_extensions" could not be resolved from source (reportMissingModuleSource)

from .types.embed import Embed as EmbedData, EmbedType

Expand Down
Loading