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
@@ -782,6 +783,9 @@ async def edit(
782783 reason : str | None = None ,
783784 communication_disabled_until : datetime .datetime | None = MISSING ,
784785 bypass_verification : bool | None = MISSING ,
786+ banner : bytes | None = MISSING ,
787+ avatar : bytes | None = MISSING ,
788+ bio : str | None = MISSING ,
785789 ) -> Member | None :
786790 """|coro|
787791
@@ -817,6 +821,14 @@ async def edit(
817821
818822 - Client has ALL THREE of :attr:`Permissions.moderate_members`, :attr:`Permissions.kick_members`, and :attr:`Permissions.ban_members`
819823
824+ .. note::
825+
826+ The following parameters are only available when editing the bot's own member:
827+
828+ - ``avatar``
829+ - ``banner``
830+ - ``bio``
831+
820832 All parameters are optional.
821833
822834 .. versionchanged:: 1.1
@@ -854,6 +866,26 @@ async def edit(
854866 Indicates if the member should bypass the guild's verification requirements.
855867
856868 .. versionadded:: 2.6
869+ banner: Optional[:class:`bytes`]
870+ A :term:`py:bytes-like object` representing the banner.
871+ Could be ``None`` to denote removal of the banner.
872+
873+ This is only available when editing the bot's own member (i.e. :attr:`Guild.me`).
874+
875+ .. versionadded:: 2.7
876+ avatar: Optional[:class:`bytes`]
877+ A :term:`py:bytes-like object` representing the avatar.
878+ Could be ``None`` to denote removal of the avatar.
879+
880+ This is only available when editing the bot's own member (i.e. :attr:`Guild.me`).
881+
882+ .. versionadded:: 2.7
883+ bio: Optional[:class:`str`]
884+ The new bio for the member. Could be ``None`` to denote removal of the bio.
885+
886+ This is only available when editing the bot's own member (i.e. :attr:`Guild.me`).
887+
888+ .. versionadded:: 2.7
857889
858890 Returns
859891 -------
@@ -867,16 +899,19 @@ async def edit(
867899 You do not have the proper permissions to the action requested.
868900 HTTPException
869901 The operation failed.
902+ InvalidArgument
903+ You tried to edit the avatar, banner, or bio of a member that is not the bot.
870904 """
871905 http = self ._state .http
872906 guild_id = self .guild .id
873907 me = self ._state .self_id == self .id
874908 payload : dict [str , Any ] = {}
909+ bot_payload : dict [str , Any ] = {}
875910
876911 if nick is not MISSING :
877912 nick = nick or ""
878913 if me :
879- await http . change_my_nickname ( guild_id , nick , reason = reason )
914+ bot_payload [ " nick" ] = nick
880915 else :
881916 payload ["nick" ] = nick
882917
@@ -923,9 +958,34 @@ async def edit(
923958 flags .bypasses_verification = bypass_verification
924959 payload ["flags" ] = flags .value
925960
961+ if avatar is not MISSING :
962+ if avatar is None :
963+ bot_payload ["avatar" ] = None
964+ else :
965+ bot_payload ["avatar" ] = utils ._bytes_to_base64_data (avatar )
966+
967+ if banner is not MISSING :
968+ if banner is None :
969+ bot_payload ["banner" ] = None
970+ else :
971+ bot_payload ["banner" ] = utils ._bytes_to_base64_data (banner )
972+
973+ if bio is not MISSING :
974+ bot_payload ["bio" ] = bio or ""
975+
976+ if bot_payload and not me :
977+ raise InvalidArgument (
978+ "Can only edit avatar, banner, or bio for the bot's member."
979+ )
980+
926981 if payload :
927982 data = await http .edit_member (guild_id , self .id , reason = reason , ** payload )
928- return Member (data = data , guild = self .guild , state = self ._state )
983+ elif bot_payload :
984+ data = await http .edit_member (guild_id , "@me" , reason = reason , ** bot_payload )
985+ else :
986+ return None
987+
988+ return Member (data = data , guild = self .guild , state = self ._state )
929989
930990 async def timeout (
931991 self , until : datetime .datetime | None , * , reason : str | None = None
0 commit comments