34
34
__all__ = (
35
35
"Embed" ,
36
36
"EmbedField" ,
37
+ "EmbedAuthor" ,
38
+ "EmbedFooter" ,
37
39
)
38
40
39
41
@@ -62,7 +64,7 @@ def __repr__(self) -> str:
62
64
inner = ", " .join (
63
65
(f"{ k } ={ v !r} " for k , v in self .__dict__ .items () if not k .startswith ("_" ))
64
66
)
65
- return f"EmbedProxy ({ inner } )"
67
+ return f"{ type ( self ). __name__ } ({ inner } )"
66
68
67
69
def __getattr__ (self , attr : str ) -> _EmptyEmbed :
68
70
return EmptyEmbed
@@ -103,6 +105,64 @@ class _EmbedAuthorProxy(Protocol):
103
105
proxy_icon_url : MaybeEmpty [str ]
104
106
105
107
108
+ class EmbedAuthor (EmbedProxy ):
109
+ """Represents the author on the :class:`Embed` object.
110
+
111
+ .. versionadded:: 2.5
112
+
113
+ Attributes
114
+ ----------
115
+ name: :class:`str`
116
+ The name of the author.
117
+ url: :class:`str`
118
+ The URL of the hyperlink created in the author's name.
119
+ icon_url: :class:`str`
120
+ The URL of the author icon image.
121
+ """
122
+
123
+ def __init__ (
124
+ self ,
125
+ name : str ,
126
+ url : MaybeEmpty [str ] = EmptyEmbed ,
127
+ icon_url : MaybeEmpty [str ] = EmptyEmbed ,
128
+ proxy_icon_url : MaybeEmpty [str ] = EmptyEmbed ,
129
+ ) -> None :
130
+ layer = {
131
+ k : v
132
+ for k , v in locals ().items ()
133
+ if k in {"name" , "url" , "icon_url" , "proxy_icon_url" }
134
+ and v is not EmptyEmbed
135
+ }
136
+ super ().__init__ (layer )
137
+
138
+
139
+ class EmbedFooter (EmbedProxy ):
140
+ """Represents the footer on the :class:`Embed` object.
141
+
142
+ .. versionadded:: 2.5
143
+
144
+ Attributes
145
+ ----------
146
+ text: :class:`str`
147
+ The text inside the footer.
148
+ icon_url: :class:`str`
149
+ The URL of the footer icon image.
150
+ """
151
+
152
+ def __init__ (
153
+ self ,
154
+ text : str ,
155
+ icon_url : MaybeEmpty [str ] = EmptyEmbed ,
156
+ proxy_icon_url : MaybeEmpty [str ] = EmptyEmbed ,
157
+ ) -> None :
158
+ layer = {
159
+ k : v
160
+ for k , v in locals ().items ()
161
+ if k in {"text" , "icon_url" , "proxy_icon_url" } and v is not EmptyEmbed
162
+ }
163
+ super ().__init__ (layer )
164
+
165
+
106
166
class EmbedField :
107
167
"""Represents a field on the :class:`Embed` object.
108
168
@@ -246,6 +306,10 @@ def __init__(
246
306
description : MaybeEmpty [Any ] = EmptyEmbed ,
247
307
timestamp : datetime .datetime = None ,
248
308
fields : list [EmbedField ] | None = None ,
309
+ author : MaybeEmpty [EmbedAuthor ] = EmptyEmbed ,
310
+ footer : MaybeEmpty [EmbedFooter ] = EmptyEmbed ,
311
+ image : MaybeEmpty [str ] = EmptyEmbed ,
312
+ thumbnail : MaybeEmpty [str ] = EmptyEmbed ,
249
313
):
250
314
self .colour = colour if colour is not EmptyEmbed else color
251
315
self .title = title
@@ -266,6 +330,18 @@ def __init__(
266
330
self .timestamp = timestamp
267
331
self ._fields : list [EmbedField ] = fields or []
268
332
333
+ if author is not EmptyEmbed :
334
+ self .set_author (** author .__dict__ )
335
+
336
+ if footer is not EmptyEmbed :
337
+ self .set_footer (** footer .__dict__ )
338
+
339
+ if image is not EmptyEmbed :
340
+ self .set_image (url = image )
341
+
342
+ if thumbnail is not EmptyEmbed :
343
+ self .set_thumbnail (url = thumbnail )
344
+
269
345
@classmethod
270
346
def from_dict (cls : type [E ], data : Mapping [str , Any ]) -> E :
271
347
"""Converts a :class:`dict` to a :class:`Embed` provided it is in the
@@ -426,14 +502,14 @@ def timestamp(self, value: MaybeEmpty[datetime.datetime]):
426
502
)
427
503
428
504
@property
429
- def footer (self ) -> _EmbedFooterProxy :
505
+ def footer (self ) -> EmbedFooter :
430
506
"""Returns an ``EmbedProxy`` denoting the footer contents.
431
507
432
508
See :meth:`set_footer` for possible values you can access.
433
509
434
510
If the attribute has no value then :attr:`Empty` is returned.
435
511
"""
436
- return EmbedProxy ( getattr (self , "_footer" , {})) # type: ignore
512
+ return EmbedFooter ( ** getattr (self , "_footer" , {}))
437
513
438
514
def set_footer (
439
515
self : E ,
@@ -618,14 +694,14 @@ def provider(self) -> _EmbedProviderProxy:
618
694
return EmbedProxy (getattr (self , "_provider" , {})) # type: ignore
619
695
620
696
@property
621
- def author (self ) -> _EmbedAuthorProxy :
697
+ def author (self ) -> EmbedAuthor :
622
698
"""Returns an ``EmbedProxy`` denoting the author contents.
623
699
624
700
See :meth:`set_author` for possible values you can access.
625
701
626
702
If the attribute has no value then :attr:`Empty` is returned.
627
703
"""
628
- return EmbedProxy ( getattr (self , "_author" , {})) # type: ignore
704
+ return EmbedAuthor ( ** getattr (self , "_author" , {})) # type: ignore
629
705
630
706
def set_author (
631
707
self : E ,
0 commit comments