Skip to content

Commit 530f3d4

Browse files
Braandnpre-commit-ci[bot]plun1331
authored
feat: add banner to ClientUser.edit (Pycord-Development#2396)
Signed-off-by: Brandon <[email protected]> Signed-off-by: plun1331 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: plun1331 <[email protected]>
1 parent 0c68e5f commit 530f3d4

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ possible (see our [Version Guarantees] for more info).
1010

1111
These changes are available on the `master` branch, but have not yet been released.
1212

13+
### Added
14+
15+
- Added `banner` parameter to `ClientUser.edit`.
16+
([#2396](https://github.com/Pycord-Development/pycord/pull/2396))
17+
1318
### Fixed
1419

1520
- Fixed the type-hinting of `Member.move_to` and `Member.edit` to reflect actual

discord/user.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,31 +422,41 @@ def _update(self, data: UserPayload) -> None:
422422

423423
# TODO: Username might not be able to edit anymore.
424424
async def edit(
425-
self, *, username: str = MISSING, avatar: bytes = MISSING
425+
self,
426+
*,
427+
username: str = MISSING,
428+
avatar: bytes = MISSING,
429+
banner: bytes = MISSING,
426430
) -> ClientUser:
427431
"""|coro|
428432
429433
Edits the current profile of the client.
430434
431435
.. note::
432436
433-
To upload an avatar, a :term:`py:bytes-like object` must be passed in that
437+
To upload an avatar or banner, a :term:`py:bytes-like object` must be passed in that
434438
represents the image being uploaded. If this is done through a file
435439
then the file must be opened via ``open('some_filename', 'rb')`` and
436440
the :term:`py:bytes-like object` is given through the use of ``fp.read()``.
437441
438-
The only image formats supported for uploading is JPEG and PNG.
442+
The only image formats supported for uploading are JPEG, PNG, and GIF.
439443
440444
.. versionchanged:: 2.0
441445
The edit is no longer in-place, instead the newly edited client user is returned.
442446
447+
.. versionchanged:: 2.6
448+
The ``banner`` keyword-only parameter was added.
449+
443450
Parameters
444451
----------
445452
username: :class:`str`
446453
The new username you wish to change to.
447454
avatar: :class:`bytes`
448455
A :term:`py:bytes-like object` representing the image to upload.
449456
Could be ``None`` to denote no avatar.
457+
banner: :class:`bytes`
458+
A :term:`py:bytes-like object` representing the image to upload.
459+
Could be ``None`` to denote no banner.
450460
451461
Returns
452462
-------
@@ -458,7 +468,7 @@ async def edit(
458468
HTTPException
459469
Editing your profile failed.
460470
InvalidArgument
461-
Wrong image format passed for ``avatar``.
471+
Wrong image format passed for ``avatar`` or ``banner``.
462472
"""
463473
payload: dict[str, Any] = {}
464474
if username is not MISSING:
@@ -469,6 +479,11 @@ async def edit(
469479
elif avatar is not MISSING:
470480
payload["avatar"] = _bytes_to_base64_data(avatar)
471481

482+
if banner is None:
483+
payload["banner"] = None
484+
elif banner is not MISSING:
485+
payload["banner"] = _bytes_to_base64_data(banner)
486+
472487
data: UserPayload = await self._state.http.edit_profile(payload)
473488
return ClientUser(state=self._state, data=data)
474489

0 commit comments

Comments
 (0)