Browse Source

Move to a property and fix repr()

pull/10126/head
dolfies 1 month ago
parent
commit
e7fb9565f5
  1. 13
      discord/embeds.py

13
discord/embeds.py

@ -46,7 +46,7 @@ class EmbedProxy:
return len(self.__dict__) return len(self.__dict__)
def __repr__(self) -> str: def __repr__(self) -> str:
inner = ', '.join((f'{k}={v!r}' for k, v in self.__dict__.items() if not k.startswith('_'))) inner = ', '.join((f'{k}={getattr(self, k)!r}' for k in dir(self) if not k.startswith('_')))
return f'EmbedProxy({inner})' return f'EmbedProxy({inner})'
def __getattr__(self, attr: str) -> None: def __getattr__(self, attr: str) -> None:
@ -57,10 +57,13 @@ class EmbedProxy:
class EmbedMediaProxy(EmbedProxy): class EmbedMediaProxy(EmbedProxy):
def __getattribute__(self, name: str) -> Any: def __init__(self, layer: Dict[str, Any]):
if name == 'flags': super().__init__(layer)
return AttachmentFlags._from_value(self.__dict__.get('flags', 0)) self._flags = self.__dict__.pop('flags', 0)
return super().__getattribute__(name)
@property
def flags(self) -> AttachmentFlags:
return AttachmentFlags._from_value(self._flags or 0)
if TYPE_CHECKING: if TYPE_CHECKING:

Loading…
Cancel
Save