mirror of
				https://github.com/Rapptz/discord.py.git
				synced 2025-10-31 05:23:03 +00:00 
			
		
		
		
	Add support for ClientUser editing banners
This commit is contained in:
		| @@ -398,7 +398,9 @@ class ClientUser(BaseUser): | |||||||
|         self._flags = data.get('flags', 0) |         self._flags = data.get('flags', 0) | ||||||
|         self.mfa_enabled = data.get('mfa_enabled', False) |         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| |         """|coro| | ||||||
|  |  | ||||||
|         Edits the current profile of the client. |         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. |             A :term:`py:bytes-like object` representing the image to upload. | ||||||
|             Could be ``None`` to denote no avatar. |             Could be ``None`` to denote no avatar. | ||||||
|             Only image formats supported for uploading are JPEG, PNG, GIF, and WEBP. |             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 |         Raises | ||||||
|         ------ |         ------ | ||||||
| @@ -449,6 +457,12 @@ class ClientUser(BaseUser): | |||||||
|             else: |             else: | ||||||
|                 payload['avatar'] = None |                 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) |         data: UserPayload = await self._state.http.edit_profile(payload) | ||||||
|         return ClientUser(state=self._state, data=data) |         return ClientUser(state=self._state, data=data) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user