Skip to content

Commit

Permalink
EmbedAuthor, EmbedFooter as return types
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhozic committed Apr 2, 2023
1 parent 280e597 commit 65417f1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions discord/embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __repr__(self) -> str:
inner = ", ".join(
(f"{k}={v!r}" for k, v in self.__dict__.items() if not k.startswith("_"))
)
return f"EmbedProxy({inner})"
return f"{type(self).__name__}({inner})"

def __getattr__(self, attr: str) -> _EmptyEmbed:
return EmptyEmbed
Expand Down Expand Up @@ -125,11 +125,12 @@ def __init__(
name: str,
url: MaybeEmpty[str] = EmptyEmbed,
icon_url: MaybeEmpty[str] = EmptyEmbed,
proxy_icon_url: MaybeEmpty[str] = EmptyEmbed
) -> None:
layer = {
k: v
for k, v in locals().items()
if k in {"name", "url", "icon_url"} and v is not EmptyEmbed
if k in {"name", "url", "icon_url", "proxy_icon_url"} and v is not EmptyEmbed
}
super().__init__(layer)

Expand All @@ -151,11 +152,12 @@ def __init__(
self,
text: str,
icon_url: MaybeEmpty[str] = EmptyEmbed,
proxy_icon_url: MaybeEmpty[str] = EmptyEmbed
) -> None:
layer = {
k: v
for k, v in locals().items()
if k in {"text", "icon_url"} and v is not EmptyEmbed
if k in {"text", "icon_url", "proxy_icon_url"} and v is not EmptyEmbed
}
super().__init__(layer)

Expand Down Expand Up @@ -499,14 +501,14 @@ def timestamp(self, value: MaybeEmpty[datetime.datetime]):
)

@property
def footer(self) -> _EmbedFooterProxy:
def footer(self) -> EmbedFooter:
"""Returns an ``EmbedProxy`` denoting the footer contents.
See :meth:`set_footer` for possible values you can access.
If the attribute has no value then :attr:`Empty` is returned.
"""
return EmbedProxy(getattr(self, "_footer", {})) # type: ignore
return EmbedFooter(**getattr(self, "_footer", {}))

def set_footer(
self: E,
Expand Down Expand Up @@ -691,14 +693,14 @@ def provider(self) -> _EmbedProviderProxy:
return EmbedProxy(getattr(self, "_provider", {})) # type: ignore

@property
def author(self) -> _EmbedAuthorProxy:
def author(self) -> EmbedAuthor:
"""Returns an ``EmbedProxy`` denoting the author contents.
See :meth:`set_author` for possible values you can access.
If the attribute has no value then :attr:`Empty` is returned.
"""
return EmbedProxy(getattr(self, "_author", {})) # type: ignore
return EmbedAuthor(**getattr(self, "_author", {})) # type: ignore

def set_author(
self: E,
Expand Down

0 comments on commit 65417f1

Please sign in to comment.