3939from .asset import Asset
4040from .colour import Colour
4141from .enums import Status , try_enum
42+ from .errors import InvalidArgument
4243from .flags import MemberFlags
4344from .object import Object
4445from .permissions import Permissions
@@ -769,6 +770,9 @@ async def edit(
769770 reason : str | None = None ,
770771 communication_disabled_until : datetime .datetime | None = MISSING ,
771772 bypass_verification : bool | None = MISSING ,
773+ banner : bytes | None = MISSING ,
774+ avatar : bytes | None = MISSING ,
775+ bio : str | None = MISSING ,
772776 ) -> Member | None :
773777 """|coro|
774778
@@ -804,6 +808,14 @@ async def edit(
804808
805809 - Client has ALL THREE of :attr:`Permissions.moderate_members`, :attr:`Permissions.kick_members`, and :attr:`Permissions.ban_members`
806810
811+ .. note::
812+
813+ The following parameters are only available when editing the bot's own member:
814+
815+ - ``avatar``
816+ - ``banner``
817+ - ``bio``
818+
807819 All parameters are optional.
808820
809821 .. versionchanged:: 1.1
@@ -841,6 +853,26 @@ async def edit(
841853 Indicates if the member should bypass the guild's verification requirements.
842854
843855 .. versionadded:: 2.6
856+ banner: Optional[:class:`bytes`]
857+ A :term:`py:bytes-like object` representing the banner.
858+ Could be ``None`` to denote removal of the banner.
859+
860+ This is only available when editing the bot's own member (i.e. :attr:`Guild.me`).
861+
862+ .. versionadded:: 2.7
863+ avatar: Optional[:class:`bytes`]
864+ A :term:`py:bytes-like object` representing the avatar.
865+ Could be ``None`` to denote removal of the avatar.
866+
867+ This is only available when editing the bot's own member (i.e. :attr:`Guild.me`).
868+
869+ .. versionadded:: 2.7
870+ bio: Optional[:class:`str`]
871+ The new bio for the member. Could be ``None`` to denote removal of the bio.
872+
873+ This is only available when editing the bot's own member (i.e. :attr:`Guild.me`).
874+
875+ .. versionadded:: 2.7
844876
845877 Returns
846878 -------
@@ -854,16 +886,19 @@ async def edit(
854886 You do not have the proper permissions to the action requested.
855887 HTTPException
856888 The operation failed.
889+ InvalidArgument
890+ You tried to edit the avatar, banner, or bio of a member that is not the bot.
857891 """
858892 http = self ._state .http
859893 guild_id = self .guild .id
860894 me = self ._state .self_id == self .id
861895 payload : dict [str , Any ] = {}
896+ bot_payload : dict [str , Any ] = {}
862897
863898 if nick is not MISSING :
864899 nick = nick or ""
865900 if me :
866- await http . change_my_nickname ( guild_id , nick , reason = reason )
901+ bot_payload [ " nick" ] = nick
867902 else :
868903 payload ["nick" ] = nick
869904
@@ -910,9 +945,34 @@ async def edit(
910945 flags .bypasses_verification = bypass_verification
911946 payload ["flags" ] = flags .value
912947
948+ if avatar is not MISSING :
949+ if avatar is None :
950+ bot_payload ["avatar" ] = None
951+ else :
952+ bot_payload ["avatar" ] = utils ._bytes_to_base64_data (avatar )
953+
954+ if banner is not MISSING :
955+ if banner is None :
956+ bot_payload ["banner" ] = None
957+ else :
958+ bot_payload ["banner" ] = utils ._bytes_to_base64_data (banner )
959+
960+ if bio is not MISSING :
961+ bot_payload ["bio" ] = bio or ""
962+
963+ if bot_payload and not me :
964+ raise InvalidArgument (
965+ "Can only edit avatar, banner, or bio for the bot's member."
966+ )
967+
913968 if payload :
914969 data = await http .edit_member (guild_id , self .id , reason = reason , ** payload )
915- return Member (data = data , guild = self .guild , state = self ._state )
970+ elif bot_payload :
971+ data = await http .edit_member (guild_id , "@me" , reason = reason , ** bot_payload )
972+ else :
973+ return None
974+
975+ return Member (data = data , guild = self .guild , state = self ._state )
916976
917977 async def timeout (
918978 self , until : datetime .datetime | None , * , reason : str | None = None
0 commit comments