Skip to content

feat: allow for editing the bot's banner #1638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions interactions/models/discord/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion interactions/models/discord/user.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down