@@ -422,31 +422,41 @@ def _update(self, data: UserPayload) -> None:
422
422
423
423
# TODO: Username might not be able to edit anymore.
424
424
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 ,
426
430
) -> ClientUser :
427
431
"""|coro|
428
432
429
433
Edits the current profile of the client.
430
434
431
435
.. note::
432
436
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
434
438
represents the image being uploaded. If this is done through a file
435
439
then the file must be opened via ``open('some_filename', 'rb')`` and
436
440
the :term:`py:bytes-like object` is given through the use of ``fp.read()``.
437
441
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 .
439
443
440
444
.. versionchanged:: 2.0
441
445
The edit is no longer in-place, instead the newly edited client user is returned.
442
446
447
+ .. versionchanged:: 2.6
448
+ The ``banner`` keyword-only parameter was added.
449
+
443
450
Parameters
444
451
----------
445
452
username: :class:`str`
446
453
The new username you wish to change to.
447
454
avatar: :class:`bytes`
448
455
A :term:`py:bytes-like object` representing the image to upload.
449
456
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.
450
460
451
461
Returns
452
462
-------
@@ -458,7 +468,7 @@ async def edit(
458
468
HTTPException
459
469
Editing your profile failed.
460
470
InvalidArgument
461
- Wrong image format passed for ``avatar``.
471
+ Wrong image format passed for ``avatar`` or ``banner`` .
462
472
"""
463
473
payload : dict [str , Any ] = {}
464
474
if username is not MISSING :
@@ -469,6 +479,11 @@ async def edit(
469
479
elif avatar is not MISSING :
470
480
payload ["avatar" ] = _bytes_to_base64_data (avatar )
471
481
482
+ if banner is None :
483
+ payload ["banner" ] = None
484
+ elif banner is not MISSING :
485
+ payload ["banner" ] = _bytes_to_base64_data (banner )
486
+
472
487
data : UserPayload = await self ._state .http .edit_profile (payload )
473
488
return ClientUser (state = self ._state , data = data )
474
489
0 commit comments