From 1ee20df5011bbd45c638421c69614afa0ffc4b08 Mon Sep 17 00:00:00 2001 From: AstreaTSS <25420078+AstreaTSS@users.noreply.github.com> Date: Tue, 19 Mar 2024 00:24:26 -0400 Subject: [PATCH] feat: allow for editing the bot's banner --- interactions/models/discord/user.py | 17 ++++++++++++++--- interactions/models/discord/user.pyi | 8 +++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/interactions/models/discord/user.py b/interactions/models/discord/user.py index bb2605738..308ef8456 100644 --- a/interactions/models/discord/user.py +++ b/interactions/models/discord/user.py @@ -239,12 +239,18 @@ def guilds(self) -> List["Guild"]: """The guilds the user is in.""" return list(filter(None, (self._client.cache.get_guild(guild_id) for guild_id in self._guild_ids))) - async def edit(self, *, username: Absent[str] = MISSING, avatar: Absent[UPLOADABLE_TYPE] = MISSING) -> None: + async def edit( + self, + *, + username: Absent[str] = MISSING, + avatar: Absent[UPLOADABLE_TYPE] = MISSING, + banner: Absent[UPLOADABLE_TYPE] = MISSING, + ) -> None: """ Edit the client's user. - You can either change the username, or avatar, or both at once. - `avatar` may be set to `None` to remove your bot's avatar + You can change the username, avatar, and banner, or any combination of the three. + `avatar` and `banner` may be set to `None` to remove your bot's avatar/banner ??? Hint "Example Usage:" ```python @@ -258,6 +264,7 @@ async def edit(self, *, username: Absent[str] = MISSING, avatar: Absent[UPLOADAB Args: username: The username you want to use avatar: The avatar to use. Can be a image file, path, or `bytes` (see example) + banner: The banner to use. Can be a image file, path, or `bytes` Raises: TooManyChanges: If you change the profile too many times @@ -270,6 +277,10 @@ async def edit(self, *, username: Absent[str] = MISSING, avatar: Absent[UPLOADAB payload["avatar"] = to_image_data(avatar) elif avatar is None: payload["avatar"] = None + if banner: + payload["banner"] = to_image_data(banner) + elif banner is None: + payload["banner"] = None try: resp = await self._client.http.modify_client_user(payload) diff --git a/interactions/models/discord/user.pyi b/interactions/models/discord/user.pyi index c91508c6e..1105a3c32 100644 --- a/interactions/models/discord/user.pyi +++ b/interactions/models/discord/user.pyi @@ -95,7 +95,13 @@ class ClientUser(User): def _add_guilds(self, guild_ids: Set["Snowflake_Type"]) -> None: ... @property def guilds(self) -> List["Guild"]: ... - async def edit(self, *, username: Absent[str] = ..., avatar: Absent[UPLOADABLE_TYPE] = ...) -> None: ... + async def edit( + self, + *, + username: Absent[str] = ..., + avatar: Absent[UPLOADABLE_TYPE] = ..., + banner: Absent[UPLOADABLE_TYPE] = ..., + ) -> None: ... @attrs.define(eq=False, order=False, hash=False, kw_only=True) class Member(FakeUserMixin):