Skip to content

Commit 670a47b

Browse files
authored
feat: allow for editing the bot's banner (#1638)
1 parent 57e4f77 commit 670a47b

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

interactions/models/discord/user.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,18 @@ def guilds(self) -> List["Guild"]:
239239
"""The guilds the user is in."""
240240
return list(filter(None, (self._client.cache.get_guild(guild_id) for guild_id in self._guild_ids)))
241241

242-
async def edit(self, *, username: Absent[str] = MISSING, avatar: Absent[UPLOADABLE_TYPE] = MISSING) -> None:
242+
async def edit(
243+
self,
244+
*,
245+
username: Absent[str] = MISSING,
246+
avatar: Absent[UPLOADABLE_TYPE] = MISSING,
247+
banner: Absent[UPLOADABLE_TYPE] = MISSING,
248+
) -> None:
243249
"""
244250
Edit the client's user.
245251
246-
You can either change the username, or avatar, or both at once.
247-
`avatar` may be set to `None` to remove your bot's avatar
252+
You can change the username, avatar, and banner, or any combination of the three.
253+
`avatar` and `banner` may be set to `None` to remove your bot's avatar/banner
248254
249255
??? Hint "Example Usage:"
250256
```python
@@ -258,6 +264,7 @@ async def edit(self, *, username: Absent[str] = MISSING, avatar: Absent[UPLOADAB
258264
Args:
259265
username: The username you want to use
260266
avatar: The avatar to use. Can be a image file, path, or `bytes` (see example)
267+
banner: The banner to use. Can be a image file, path, or `bytes`
261268
262269
Raises:
263270
TooManyChanges: If you change the profile too many times
@@ -270,6 +277,10 @@ async def edit(self, *, username: Absent[str] = MISSING, avatar: Absent[UPLOADAB
270277
payload["avatar"] = to_image_data(avatar)
271278
elif avatar is None:
272279
payload["avatar"] = None
280+
if banner:
281+
payload["banner"] = to_image_data(banner)
282+
elif banner is None:
283+
payload["banner"] = None
273284

274285
try:
275286
resp = await self._client.http.modify_client_user(payload)

interactions/models/discord/user.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ class ClientUser(User):
9595
def _add_guilds(self, guild_ids: Set["Snowflake_Type"]) -> None: ...
9696
@property
9797
def guilds(self) -> List["Guild"]: ...
98-
async def edit(self, *, username: Absent[str] = ..., avatar: Absent[UPLOADABLE_TYPE] = ...) -> None: ...
98+
async def edit(
99+
self,
100+
*,
101+
username: Absent[str] = ...,
102+
avatar: Absent[UPLOADABLE_TYPE] = ...,
103+
banner: Absent[UPLOADABLE_TYPE] = ...,
104+
) -> None: ...
99105

100106
@attrs.define(eq=False, order=False, hash=False, kw_only=True)
101107
class Member(FakeUserMixin):

0 commit comments

Comments
 (0)