From 7e6a212f9f54bdd6d818a2099a07e7f1bc2f6d1f Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Tue, 13 Aug 2024 23:28:45 +0200 Subject: [PATCH 01/22] implement local files for more embed methods --- disnake/embeds.py | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 1866d8d7eb..3da9a2e010 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -106,7 +106,7 @@ class _EmbedAuthorProxy(Sized, Protocol): icon_url: Optional[str] proxy_icon_url: Optional[str] - _FileKey = Literal["image", "thumbnail"] + _FileKey = Literal["image", "thumbnail", "footer", "author"] class Embed: @@ -385,12 +385,20 @@ def footer(self) -> _EmbedFooterProxy: """ return cast("_EmbedFooterProxy", EmbedProxy(self._footer)) - def set_footer(self, *, text: Any, icon_url: Optional[Any] = None) -> Self: + def set_footer( + self, *, text: Any, icon_url: Optional[Any] = MISSING, file: File = MISSING + ) -> Self: """Sets the footer for the embed content. This function returns the class instance to allow for fluent-style chaining. + Exactly one of ``icon_url`` or ``file`` should be passed at a time, if passed. + + .. warning:: + Passing a :class:`disnake.File` object will make the embed not + reusable. + Parameters ---------- text: :class:`str` @@ -401,13 +409,18 @@ def set_footer(self, *, text: Any, icon_url: Optional[Any] = None) -> Self: icon_url: Optional[:class:`str`] The URL of the footer icon. Only HTTP(S) is supported. + file: :clas:`File` + The file to use as the image. + + .. versionadded:: 2.10 """ self._footer = { "text": str(text), } - if icon_url is not None: - self._footer["icon_url"] = str(icon_url) + result = self._handle_resource(icon_url, file, key="footer") + if result is not None: + self._footer["icon_url"] = result return self @@ -564,13 +577,20 @@ def set_author( *, name: Any, url: Optional[Any] = None, - icon_url: Optional[Any] = None, + icon_url: Optional[Any] = MISSING, + file: File = MISSING, ) -> Self: """Sets the author for the embed content. This function returns the class instance to allow for fluent-style chaining. + Exactly one of ``icon_url`` or ``file`` should be passed at a time, if passed. + + .. warning:: + Passing a :class:`disnake.File` object will make the embed not + reusable. + Parameters ---------- name: :class:`str` @@ -579,6 +599,10 @@ def set_author( The URL for the author. icon_url: Optional[:class:`str`] The URL of the author icon. Only HTTP(S) is supported. + file: :clas:`File` + The file to use as the image. + + .. versionadded:: 2.10 """ self._author = { "name": str(name), @@ -587,8 +611,9 @@ def set_author( if url is not None: self._author["url"] = str(url) - if icon_url is not None: - self._author["icon_url"] = str(icon_url) + result = self._handle_resource(icon_url, file, key="author") + if result is not None: + self._author["icon_url"] = result return self From cbcccd91133b5a00399e3e5ba3ef1be688594594 Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Tue, 13 Aug 2024 23:39:32 +0200 Subject: [PATCH 02/22] add changelog --- changelog/1184.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/1184.feature.rst diff --git a/changelog/1184.feature.rst b/changelog/1184.feature.rst new file mode 100644 index 0000000000..243bf38dea --- /dev/null +++ b/changelog/1184.feature.rst @@ -0,0 +1 @@ +Add the possibility to pass :class:`disnake.File` objects to :meth:`~Embed.set_author` and :meth:`~Embed.set_icon`. From 6c0038bd902805f1ca8fe4ba6b1d42ce0bcd7aee Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:00:47 +0200 Subject: [PATCH 03/22] mention uniqueness constraint for File names --- disnake/embeds.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/disnake/embeds.py b/disnake/embeds.py index 3da9a2e010..7a7ec8525b 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -399,6 +399,11 @@ def set_footer( Passing a :class:`disnake.File` object will make the embed not reusable. + .. note:: + If used with the other ``set_*`` methods you must ensure + that the :attr:`.File.filename` is different than the other file(s) + that you are passing. + Parameters ---------- text: :class:`str` @@ -470,6 +475,11 @@ def set_image(self, url: Optional[Any] = MISSING, *, file: File = MISSING) -> Se Passing a :class:`disnake.File` object will make the embed not reusable. + .. note:: + If used with the other ``set_*`` methods you must ensure + that the :attr:`.File.filename` is different than the other file(s) + that you are passing. + .. versionchanged:: 1.4 Passing ``None`` removes the image. @@ -521,6 +531,11 @@ def set_thumbnail(self, url: Optional[Any] = MISSING, *, file: File = MISSING) - Passing a :class:`disnake.File` object will make the embed not reusable. + .. note:: + If used with the other ``set_*`` methods you must ensure + that the :attr:`.File.filename` is different than the other file(s) + that you are passing. + .. versionchanged:: 1.4 Passing ``None`` removes the thumbnail. @@ -591,6 +606,11 @@ def set_author( Passing a :class:`disnake.File` object will make the embed not reusable. + .. note:: + If used with the other ``set_*`` methods you must ensure + that the :attr:`.File.filename` is different than the other file(s) + that you are passing. + Parameters ---------- name: :class:`str` From 70e43bd5783a3fcbfbd4e9b64f088d7e2361a2ba Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:11:00 +0200 Subject: [PATCH 04/22] add overloads --- disnake/embeds.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/disnake/embeds.py b/disnake/embeds.py index 7a7ec8525b..312edce2c9 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -385,6 +385,14 @@ def footer(self) -> _EmbedFooterProxy: """ return cast("_EmbedFooterProxy", EmbedProxy(self._footer)) + @overload + def set_footer(self, *, text: Any, icon_url: Optional[Any]) -> Self: + ... + + @overload + def set_footer(self, *, text: Any, file: File) -> Self: + ... + def set_footer( self, *, text: Any, icon_url: Optional[Any] = MISSING, file: File = MISSING ) -> Self: @@ -587,6 +595,14 @@ def author(self) -> _EmbedAuthorProxy: """ return cast("_EmbedAuthorProxy", EmbedProxy(self._author)) + @overload + def set_author(self, *, name: Any, url: Optional[Any], icon_url: Optional[Any]) -> Self: + ... + + @overload + def set_author(self, *, name: Any, url: Optional[Any], file: File) -> Self: + ... + def set_author( self, *, From 59dd7006dbf31b4f3788e2785bde66fe827fed14 Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:13:04 +0200 Subject: [PATCH 05/22] fix overloads --- disnake/embeds.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 312edce2c9..724cc5967b 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -386,11 +386,11 @@ def footer(self) -> _EmbedFooterProxy: return cast("_EmbedFooterProxy", EmbedProxy(self._footer)) @overload - def set_footer(self, *, text: Any, icon_url: Optional[Any]) -> Self: + def set_footer(self, *, text: Any, icon_url: Optional[Any] = ...) -> Self: ... @overload - def set_footer(self, *, text: Any, file: File) -> Self: + def set_footer(self, *, text: Any, file: File = ...) -> Self: ... def set_footer( @@ -596,11 +596,13 @@ def author(self) -> _EmbedAuthorProxy: return cast("_EmbedAuthorProxy", EmbedProxy(self._author)) @overload - def set_author(self, *, name: Any, url: Optional[Any], icon_url: Optional[Any]) -> Self: + def set_author( + self, *, name: Any, url: Optional[Any] = ..., icon_url: Optional[Any] = ... + ) -> Self: ... @overload - def set_author(self, *, name: Any, url: Optional[Any], file: File) -> Self: + def set_author(self, *, name: Any, url: Optional[Any] = ..., file: File = ...) -> Self: ... def set_author( From b5bc743be00d03bab2e22cff8c80d8a8c5170a6f Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:34:16 +0200 Subject: [PATCH 06/22] make tests pass --- disnake/embeds.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 724cc5967b..8e20cafc43 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -431,7 +431,7 @@ def set_footer( "text": str(text), } - result = self._handle_resource(icon_url, file, key="footer") + result = self._handle_resource(icon_url, file, key="footer", strict=False) if result is not None: self._footer["icon_url"] = result @@ -649,7 +649,9 @@ def set_author( if url is not None: self._author["url"] = str(url) - result = self._handle_resource(icon_url, file, key="author") + result = self._handle_resource( + icon_url if icon_url else None, file, key="author", strict=False + ) if result is not None: self._author["icon_url"] = result @@ -884,9 +886,15 @@ def get_default_colour(cls) -> Optional[Colour]: get_default_color = get_default_colour - def _handle_resource(self, url: Optional[Any], file: File, *, key: _FileKey) -> Optional[str]: - if not (url is MISSING) ^ (file is MISSING): - raise TypeError("Exactly one of url or file must be provided") + def _handle_resource( + self, url: Optional[Any], file: File, *, key: _FileKey, strict: bool = True + ) -> Optional[str]: + if strict: + if not (url is MISSING) ^ (file is MISSING): + raise TypeError("Exactly one of url or file must be provided") + else: + if url is not MISSING and file is not MISSING: + raise TypeError("Only one of url or file must be provided, not both.") if file: if file.filename is None: From 297e71c038b59a0b782ab4d9e3f16ec20720bc96 Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:48:10 +0200 Subject: [PATCH 07/22] fix docs --- disnake/embeds.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 8e20cafc43..337c7cb8d0 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -422,7 +422,7 @@ def set_footer( icon_url: Optional[:class:`str`] The URL of the footer icon. Only HTTP(S) is supported. - file: :clas:`File` + file: :class:`File` The file to use as the image. .. versionadded:: 2.10 @@ -637,7 +637,7 @@ def set_author( The URL for the author. icon_url: Optional[:class:`str`] The URL of the author icon. Only HTTP(S) is supported. - file: :clas:`File` + file: :class:`File` The file to use as the image. .. versionadded:: 2.10 From 81c60ec5074acb708783197ba7902f59283cd712 Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Sat, 14 Sep 2024 09:14:41 +0200 Subject: [PATCH 08/22] apply nit name suggestion --- disnake/embeds.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 337c7cb8d0..f0b0b8b07a 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -431,7 +431,7 @@ def set_footer( "text": str(text), } - result = self._handle_resource(icon_url, file, key="footer", strict=False) + result = self._handle_resource(icon_url, file, key="footer", required=False) if result is not None: self._footer["icon_url"] = result @@ -650,7 +650,7 @@ def set_author( self._author["url"] = str(url) result = self._handle_resource( - icon_url if icon_url else None, file, key="author", strict=False + icon_url if icon_url else None, file, key="author", required=False ) if result is not None: self._author["icon_url"] = result @@ -887,9 +887,9 @@ def get_default_colour(cls) -> Optional[Colour]: get_default_color = get_default_colour def _handle_resource( - self, url: Optional[Any], file: File, *, key: _FileKey, strict: bool = True + self, url: Optional[Any], file: File, *, key: _FileKey, required: bool = True ) -> Optional[str]: - if strict: + if required: if not (url is MISSING) ^ (file is MISSING): raise TypeError("Exactly one of url or file must be provided") else: From a46c38e98780565dddec3760b6b16fff5c7f90a0 Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:26:12 +0100 Subject: [PATCH 09/22] Update disnake/embeds.py Co-authored-by: shiftinv <8530778+shiftinv@users.noreply.github.com> Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> --- disnake/embeds.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index f0b0b8b07a..d55b257a27 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -408,9 +408,8 @@ def set_footer( reusable. .. note:: - If used with the other ``set_*`` methods you must ensure - that the :attr:`.File.filename` is different than the other file(s) - that you are passing. + If used with the other ``set_*`` methods, you must ensure + that the :attr:`.File.filename` is unique to avoid duplication. Parameters ---------- From 80aad9c4b137d51fc5eb4ceda136c624a0c7b454 Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:26:23 +0100 Subject: [PATCH 10/22] Update disnake/embeds.py Co-authored-by: shiftinv <8530778+shiftinv@users.noreply.github.com> Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> --- disnake/embeds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index d55b257a27..60a2c77c3e 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -422,7 +422,7 @@ def set_footer( icon_url: Optional[:class:`str`] The URL of the footer icon. Only HTTP(S) is supported. file: :class:`File` - The file to use as the image. + The file to use as the footer icon. .. versionadded:: 2.10 """ From eb4007a647d221c8e28bd9aeec92b3197ba4869b Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:27:03 +0100 Subject: [PATCH 11/22] Update disnake/embeds.py Co-authored-by: shiftinv <8530778+shiftinv@users.noreply.github.com> Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> --- disnake/embeds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 60a2c77c3e..878071ec5c 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -886,7 +886,7 @@ def get_default_colour(cls) -> Optional[Colour]: get_default_color = get_default_colour def _handle_resource( - self, url: Optional[Any], file: File, *, key: _FileKey, required: bool = True + self, url: Optional[Any], file: Optional[File], *, key: _FileKey, required: bool = True ) -> Optional[str]: if required: if not (url is MISSING) ^ (file is MISSING): From 1b842df08f7171d0d920cd62a058c47cac3214dc Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:27:11 +0100 Subject: [PATCH 12/22] Update changelog/1184.feature.rst Co-authored-by: shiftinv <8530778+shiftinv@users.noreply.github.com> Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> --- changelog/1184.feature.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/1184.feature.rst b/changelog/1184.feature.rst index 243bf38dea..32aae25dc1 100644 --- a/changelog/1184.feature.rst +++ b/changelog/1184.feature.rst @@ -1 +1 @@ -Add the possibility to pass :class:`disnake.File` objects to :meth:`~Embed.set_author` and :meth:`~Embed.set_icon`. +Add the possibility to pass :class:`disnake.File` objects to :meth:`Embed.set_author` and :meth:`~Embed.set_footer`. From 8865a33f234b3055119ffccec1df74af35de22fc Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:38:53 +0100 Subject: [PATCH 13/22] Update disnake/embeds.py Co-authored-by: shiftinv <8530778+shiftinv@users.noreply.github.com> Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> --- disnake/embeds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 878071ec5c..5fa8a5f23a 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -637,7 +637,7 @@ def set_author( icon_url: Optional[:class:`str`] The URL of the author icon. Only HTTP(S) is supported. file: :class:`File` - The file to use as the image. + The file to use as the author icon. .. versionadded:: 2.10 """ From 8c404be7b796f3ed2a3ca89c79689bd29efb1561 Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:47:37 +0100 Subject: [PATCH 14/22] feat: apply requested changes --- disnake/embeds.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 5fa8a5f23a..82153fcf0a 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -390,11 +390,11 @@ def set_footer(self, *, text: Any, icon_url: Optional[Any] = ...) -> Self: ... @overload - def set_footer(self, *, text: Any, file: File = ...) -> Self: + def set_footer(self, *, text: Any, icon_file: File = ...) -> Self: ... def set_footer( - self, *, text: Any, icon_url: Optional[Any] = MISSING, file: File = MISSING + self, *, text: Any, icon_url: Optional[Any] = MISSING, icon_file: File = MISSING ) -> Self: """Sets the footer for the embed content. @@ -421,7 +421,7 @@ def set_footer( icon_url: Optional[:class:`str`] The URL of the footer icon. Only HTTP(S) is supported. - file: :class:`File` + icon_file: :class:`File` The file to use as the footer icon. .. versionadded:: 2.10 @@ -430,7 +430,7 @@ def set_footer( "text": str(text), } - result = self._handle_resource(icon_url, file, key="footer", required=False) + result = self._handle_resource(icon_url, icon_file, key="footer", required=False) if result is not None: self._footer["icon_url"] = result @@ -601,7 +601,7 @@ def set_author( ... @overload - def set_author(self, *, name: Any, url: Optional[Any] = ..., file: File = ...) -> Self: + def set_author(self, *, name: Any, url: Optional[Any] = ..., icon_file: File = ...) -> Self: ... def set_author( @@ -610,7 +610,7 @@ def set_author( name: Any, url: Optional[Any] = None, icon_url: Optional[Any] = MISSING, - file: File = MISSING, + icon_file: File = MISSING, ) -> Self: """Sets the author for the embed content. @@ -636,7 +636,7 @@ def set_author( The URL for the author. icon_url: Optional[:class:`str`] The URL of the author icon. Only HTTP(S) is supported. - file: :class:`File` + icon_file: :class:`File` The file to use as the author icon. .. versionadded:: 2.10 @@ -648,9 +648,7 @@ def set_author( if url is not None: self._author["url"] = str(url) - result = self._handle_resource( - icon_url if icon_url else None, file, key="author", required=False - ) + result = self._handle_resource(icon_url, icon_file, key="author", required=False) if result is not None: self._author["icon_url"] = result @@ -902,7 +900,7 @@ def _handle_resource( return f"attachment://{file.filename}" else: self._files.pop(key, None) - return str(url) if url is not None else None + return str(url) if url else None def check_limits(self) -> None: """Checks if this embed fits within the limits dictated by Discord. From dbca335a0bac6fae76093dad5940c6096249d937 Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:48:12 +0100 Subject: [PATCH 15/22] Update disnake/embeds.py Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com> Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> --- disnake/embeds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 82153fcf0a..626c4473db 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -401,7 +401,7 @@ def set_footer( This function returns the class instance to allow for fluent-style chaining. - Exactly one of ``icon_url`` or ``file`` should be passed at a time, if passed. + At most one of ``icon_url`` or ``file`` may be passed. .. warning:: Passing a :class:`disnake.File` object will make the embed not From a4e1f1240568bc33e0eed8c73cb6b3016706f3ac Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:48:27 +0100 Subject: [PATCH 16/22] Update disnake/embeds.py Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com> Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> --- disnake/embeds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 626c4473db..ea8db3431a 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -617,7 +617,7 @@ def set_author( This function returns the class instance to allow for fluent-style chaining. - Exactly one of ``icon_url`` or ``file`` should be passed at a time, if passed. + At most one of ``icon_url`` or ``file`` may be passed. .. warning:: Passing a :class:`disnake.File` object will make the embed not From ef56e0074035e28cf4ab683cbbd77cc25b38c514 Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:48:39 +0100 Subject: [PATCH 17/22] Update disnake/embeds.py Co-authored-by: Eneg <42005170+Enegg@users.noreply.github.com> Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> --- disnake/embeds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index ea8db3431a..7c8e139455 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -891,7 +891,7 @@ def _handle_resource( raise TypeError("Exactly one of url or file must be provided") else: if url is not MISSING and file is not MISSING: - raise TypeError("Only one of url or file must be provided, not both.") + raise TypeError("At most one of url or file may be provided, not both.") if file: if file.filename is None: From fed19dc6270f93fc11c4e58a5714761909857b53 Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:51:49 +0100 Subject: [PATCH 18/22] feat: change file to icon_file --- disnake/embeds.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 7c8e139455..115b7e38ca 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -401,7 +401,7 @@ def set_footer( This function returns the class instance to allow for fluent-style chaining. - At most one of ``icon_url`` or ``file`` may be passed. + At most one of ``icon_url`` or ``icon_file`` may be passed. .. warning:: Passing a :class:`disnake.File` object will make the embed not @@ -617,7 +617,7 @@ def set_author( This function returns the class instance to allow for fluent-style chaining. - At most one of ``icon_url`` or ``file`` may be passed. + At most one of ``icon_url`` or ``icon_file`` may be passed. .. warning:: Passing a :class:`disnake.File` object will make the embed not From 59fe93cd71d4359dc3c7cf8331dc46687610b252 Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:53:17 +0100 Subject: [PATCH 19/22] feat: change notes to warnings --- disnake/embeds.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 115b7e38ca..70ded520a3 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -407,7 +407,7 @@ def set_footer( Passing a :class:`disnake.File` object will make the embed not reusable. - .. note:: + .. warning:: If used with the other ``set_*`` methods, you must ensure that the :attr:`.File.filename` is unique to avoid duplication. @@ -482,7 +482,7 @@ def set_image(self, url: Optional[Any] = MISSING, *, file: File = MISSING) -> Se Passing a :class:`disnake.File` object will make the embed not reusable. - .. note:: + .. warning:: If used with the other ``set_*`` methods you must ensure that the :attr:`.File.filename` is different than the other file(s) that you are passing. @@ -538,7 +538,7 @@ def set_thumbnail(self, url: Optional[Any] = MISSING, *, file: File = MISSING) - Passing a :class:`disnake.File` object will make the embed not reusable. - .. note:: + .. warning:: If used with the other ``set_*`` methods you must ensure that the :attr:`.File.filename` is different than the other file(s) that you are passing. @@ -623,7 +623,7 @@ def set_author( Passing a :class:`disnake.File` object will make the embed not reusable. - .. note:: + .. warning:: If used with the other ``set_*`` methods you must ensure that the :attr:`.File.filename` is different than the other file(s) that you are passing. From da9237e07627f1d392562b4f2166a9fd6dc4025d Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:45:17 +0100 Subject: [PATCH 20/22] Update disnake/embeds.py Co-authored-by: shiftinv <8530778+shiftinv@users.noreply.github.com> Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> --- disnake/embeds.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 70ded520a3..f23c9863eb 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -624,9 +624,8 @@ def set_author( reusable. .. warning:: - If used with the other ``set_*`` methods you must ensure - that the :attr:`.File.filename` is different than the other file(s) - that you are passing. + If used with the other ``set_*`` methods, you must ensure + that the :attr:`.File.filename` is unique to avoid duplication. Parameters ---------- From 270b1ca3fb2836247854e6cc025a996229fdba1b Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:45:31 +0100 Subject: [PATCH 21/22] Update disnake/embeds.py Co-authored-by: shiftinv <8530778+shiftinv@users.noreply.github.com> Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> --- disnake/embeds.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index f23c9863eb..810c8759a1 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -539,9 +539,8 @@ def set_thumbnail(self, url: Optional[Any] = MISSING, *, file: File = MISSING) - reusable. .. warning:: - If used with the other ``set_*`` methods you must ensure - that the :attr:`.File.filename` is different than the other file(s) - that you are passing. + If used with the other ``set_*`` methods, you must ensure + that the :attr:`.File.filename` is unique to avoid duplication. .. versionchanged:: 1.4 Passing ``None`` removes the thumbnail. From 484995fcab07e874b30c7e14d9312f98d2900284 Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:45:41 +0100 Subject: [PATCH 22/22] Update disnake/embeds.py Co-authored-by: shiftinv <8530778+shiftinv@users.noreply.github.com> Signed-off-by: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> --- disnake/embeds.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/disnake/embeds.py b/disnake/embeds.py index 810c8759a1..abbbff53f2 100644 --- a/disnake/embeds.py +++ b/disnake/embeds.py @@ -483,9 +483,8 @@ def set_image(self, url: Optional[Any] = MISSING, *, file: File = MISSING) -> Se reusable. .. warning:: - If used with the other ``set_*`` methods you must ensure - that the :attr:`.File.filename` is different than the other file(s) - that you are passing. + If used with the other ``set_*`` methods, you must ensure + that the :attr:`.File.filename` is unique to avoid duplication. .. versionchanged:: 1.4 Passing ``None`` removes the image.