@@ -815,12 +815,22 @@ async def edit(
815815 voice_channel : Optional [VocalGuildChannel ] = MISSING ,
816816 timed_out_until : Optional [datetime .datetime ] = MISSING ,
817817 bypass_verification : bool = MISSING ,
818+ avatar : Optional [bytes ] = MISSING ,
819+ banner : Optional [bytes ] = MISSING ,
820+ bio : Optional [str ] = MISSING ,
818821 reason : Optional [str ] = None ,
819822 ) -> Optional [Member ]:
820823 """|coro|
821824
822825 Edits the member's data.
823826
827+ .. note::
828+
829+ To upload an avatar or banner, a :term:`py:bytes-like object` must be passed in that
830+ represents the image being uploaded. If this is done through a file
831+ then the file must be opened via ``open('some_filename', 'rb')`` and
832+ the :term:`py:bytes-like object` is given through the use of ``fp.read()``.
833+
824834 Depending on the parameter passed, this requires different permissions listed below:
825835
826836 +---------------------+---------------------------------------+
@@ -876,6 +886,20 @@ async def edit(
876886 Indicates if the member should be allowed to bypass the guild verification requirements.
877887
878888 .. versionadded:: 2.2
889+ avatar: Optional[:class:`bytes`]
890+ A :term:`py:bytes-like object` representing the image to upload. Could be ``None`` to denote no avatar.
891+ Only image formats supported for uploading are JPEG, PNG, GIF, and WEBP.
892+ This can only be set when editing the bot's own member.
893+ .. versionadded:: 2.7
894+ banner: Optional[:class:`bytes`]
895+ A :term:`py:bytes-like object` representing the image to upload. Could be ``None`` to denote no banner.
896+ Only image formats supported for uploading are JPEG, PNG, GIF and WEBP..
897+ This can only be set when editing the bot's own member.
898+ .. versionadded:: 2.7
899+ bio: Optional[:class:`str`]
900+ The new bio for the member. Use ``None`` to remove the bio.
901+ This can only be set when editing the bot's own member.
902+ .. versionadded:: 2.7
879903
880904 reason: Optional[:class:`str`]
881905 The reason for editing this member. Shows up on the audit log.
@@ -888,6 +912,9 @@ async def edit(
888912 The operation failed.
889913 TypeError
890914 The datetime object passed to ``timed_out_until`` was not timezone-aware.
915+ ValueError
916+ You tried to edit the bio, avatar or banner of a member that is not the bot's own member.
917+ Or the wrong image format passed for ``avatar`` or ``banner``.
891918
892919 Returns
893920 --------
@@ -899,14 +926,33 @@ async def edit(
899926 guild_id = self .guild .id
900927 me = self ._state .self_id == self .id
901928 payload : Dict [str , Any ] = {}
929+ self_payload : Dict [str , Any ] = {}
902930
903931 if nick is not MISSING :
904932 nick = nick or ''
905933 if me :
906- await http . change_my_nickname ( guild_id , nick , reason = reason )
934+ self_payload [ ' nick' ] = nick
907935 else :
908936 payload ['nick' ] = nick
909937
938+ if avatar is not MISSING :
939+ if avatar is None :
940+ self_payload ['avatar' ] = None
941+ else :
942+ self_payload ['avatar' ] = utils ._bytes_to_base64_data (avatar )
943+
944+ if banner is not MISSING :
945+ if banner is None :
946+ self_payload ['banner' ] = None
947+ else :
948+ self_payload ['banner' ] = utils ._bytes_to_base64_data (banner )
949+
950+ if bio is not MISSING :
951+ self_payload ['bio' ] = bio or ''
952+
953+ if not me and self_payload :
954+ raise ValueError ("Editing the bio, avatar or banner is only for the bot's own member." )
955+
910956 if deafen is not MISSING :
911957 payload ['deaf' ] = deafen
912958
@@ -954,7 +1000,12 @@ async def edit(
9541000
9551001 if payload :
9561002 data = await http .edit_member (guild_id , self .id , reason = reason , ** payload )
957- return Member (data = data , guild = self .guild , state = self ._state )
1003+ elif self_payload :
1004+ data = await http .edit_my_member (guild_id , reason = reason , ** self_payload )
1005+ else :
1006+ return None
1007+
1008+ return Member (data = data , guild = self .guild , state = self ._state )
9581009
9591010 async def request_to_speak (self ) -> None :
9601011 """|coro|
0 commit comments