From 82d13e7b497ac8983a3567a715d5c528b2a895ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20N=C3=B8rgaard?= Date: Thu, 14 Mar 2024 22:10:17 +0000 Subject: [PATCH] Add support for ClientUser editing banners --- discord/user.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/discord/user.py b/discord/user.py index 2cffcee55..5151957dc 100644 --- a/discord/user.py +++ b/discord/user.py @@ -398,7 +398,9 @@ class ClientUser(BaseUser): self._flags = data.get('flags', 0) self.mfa_enabled = data.get('mfa_enabled', False) - async def edit(self, *, username: str = MISSING, avatar: Optional[bytes] = MISSING) -> ClientUser: + async def edit( + self, *, username: str = MISSING, avatar: Optional[bytes] = MISSING, banner: Optional[bytes] = MISSING + ) -> ClientUser: """|coro| Edits the current profile of the client. @@ -426,6 +428,12 @@ class ClientUser(BaseUser): A :term:`py:bytes-like object` representing the image to upload. Could be ``None`` to denote no avatar. Only image formats supported for uploading are JPEG, PNG, GIF, and WEBP. + banner: Optional[:class:`bytes`] + A :term:`py:bytes-like object` representing the image to upload. + Could be ``None`` to denote no banner. + Only image formats supported for uploading are JPEG, PNG, GIF and WEBP. + + .. versionadded:: 2.4 Raises ------ @@ -449,6 +457,12 @@ class ClientUser(BaseUser): else: payload['avatar'] = None + if banner is not MISSING: + if banner is not None: + payload['banner'] = _bytes_to_base64_data(banner) + else: + payload['banner'] = None + data: UserPayload = await self._state.http.edit_profile(payload) return ClientUser(state=self._state, data=data)