Skip to content

Commit 82d13e7

Browse files
Add support for ClientUser editing banners
1 parent edf7ce2 commit 82d13e7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

discord/user.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,9 @@ def _update(self, data: UserPayload) -> None:
398398
self._flags = data.get('flags', 0)
399399
self.mfa_enabled = data.get('mfa_enabled', False)
400400

401-
async def edit(self, *, username: str = MISSING, avatar: Optional[bytes] = MISSING) -> ClientUser:
401+
async def edit(
402+
self, *, username: str = MISSING, avatar: Optional[bytes] = MISSING, banner: Optional[bytes] = MISSING
403+
) -> ClientUser:
402404
"""|coro|
403405
404406
Edits the current profile of the client.
@@ -426,6 +428,12 @@ async def edit(self, *, username: str = MISSING, avatar: Optional[bytes] = MISSI
426428
A :term:`py:bytes-like object` representing the image to upload.
427429
Could be ``None`` to denote no avatar.
428430
Only image formats supported for uploading are JPEG, PNG, GIF, and WEBP.
431+
banner: Optional[:class:`bytes`]
432+
A :term:`py:bytes-like object` representing the image to upload.
433+
Could be ``None`` to denote no banner.
434+
Only image formats supported for uploading are JPEG, PNG, GIF and WEBP.
435+
436+
.. versionadded:: 2.4
429437
430438
Raises
431439
------
@@ -449,6 +457,12 @@ async def edit(self, *, username: str = MISSING, avatar: Optional[bytes] = MISSI
449457
else:
450458
payload['avatar'] = None
451459

460+
if banner is not MISSING:
461+
if banner is not None:
462+
payload['banner'] = _bytes_to_base64_data(banner)
463+
else:
464+
payload['banner'] = None
465+
452466
data: UserPayload = await self._state.http.edit_profile(payload)
453467
return ClientUser(state=self._state, data=data)
454468

0 commit comments

Comments
 (0)