Skip to content

Commit ef24f8e

Browse files
authored
Merge branch 'master' into master
Signed-off-by: plun1331 <plun1331@gmail.com>
2 parents f9d5bf5 + bfe7827 commit ef24f8e

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
- id: trailing-whitespace
1010
- id: end-of-file-fixer
1111
- repo: https://github.com/PyCQA/autoflake
12-
rev: v2.3.0
12+
rev: v2.3.1
1313
hooks:
1414
- id: autoflake
1515
# args:
@@ -28,7 +28,7 @@ repos:
2828
hooks:
2929
- id: isort
3030
- repo: https://github.com/psf/black
31-
rev: 24.2.0
31+
rev: 24.3.0
3232
hooks:
3333
- id: black
3434
args: [--safe, --quiet]

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ These changes are available on the `master` branch, but have not yet been releas
1212

1313
### Added
1414

15+
- Added `banner` parameter to `ClientUser.edit`.
16+
([#2396](https://github.com/Pycord-Development/pycord/pull/2396))
1517
- Added `user` argument to `Paginator.edit`.
1618
([#2390](https://github.com/Pycord-Development/pycord/pull/2390))
1719

1820
### Fixed
1921

2022
- Fixed the type-hinting of `Member.move_to` and `Member.edit` to reflect actual
2123
behavior. ([#2386](https://github.com/Pycord-Development/pycord/pull/2386))
24+
- Fixed a deprecation warning from being displayed when running `python -m discord -v`
25+
by replacing the deprecated module.
26+
([#2392](https://github.com/Pycord-Development/pycord/pull/2392))
2227
- Fixed `Paginator.edit` to no longer set user to the bot.
2328
([#2390](https://github.com/Pycord-Development/pycord/pull/2390))
2429

discord/__main__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
"""
2525

2626
import argparse
27+
import importlib.metadata
2728
import platform
2829
import sys
2930
from pathlib import Path
3031
from typing import Tuple
3132

3233
import aiohttp
33-
import pkg_resources
3434

3535
import discord
3636

@@ -47,9 +47,9 @@ def show_version() -> None:
4747
"- py-cord v{0.major}.{0.minor}.{0.micro}-{0.releaselevel}".format(version_info)
4848
)
4949
if version_info.releaselevel != "final":
50-
pkg = pkg_resources.get_distribution("py-cord")
51-
if pkg:
52-
entries.append(f" - py-cord pkg_resources: v{pkg.version}")
50+
version = importlib.metadata.version("py-cord")
51+
if version:
52+
entries.append(f" - py-cord importlib.metadata: v{version}")
5353

5454
entries.append(f"- aiohttp v{aiohttp.__version__}")
5555
uname = platform.uname()

discord/user.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,31 +422,41 @@ def _update(self, data: UserPayload) -> None:
422422

423423
# TODO: Username might not be able to edit anymore.
424424
async def edit(
425-
self, *, username: str = MISSING, avatar: bytes = MISSING
425+
self,
426+
*,
427+
username: str = MISSING,
428+
avatar: bytes = MISSING,
429+
banner: bytes = MISSING,
426430
) -> ClientUser:
427431
"""|coro|
428432
429433
Edits the current profile of the client.
430434
431435
.. note::
432436
433-
To upload an avatar, a :term:`py:bytes-like object` must be passed in that
437+
To upload an avatar or banner, a :term:`py:bytes-like object` must be passed in that
434438
represents the image being uploaded. If this is done through a file
435439
then the file must be opened via ``open('some_filename', 'rb')`` and
436440
the :term:`py:bytes-like object` is given through the use of ``fp.read()``.
437441
438-
The only image formats supported for uploading is JPEG and PNG.
442+
The only image formats supported for uploading are JPEG, PNG, and GIF.
439443
440444
.. versionchanged:: 2.0
441445
The edit is no longer in-place, instead the newly edited client user is returned.
442446
447+
.. versionchanged:: 2.6
448+
The ``banner`` keyword-only parameter was added.
449+
443450
Parameters
444451
----------
445452
username: :class:`str`
446453
The new username you wish to change to.
447454
avatar: :class:`bytes`
448455
A :term:`py:bytes-like object` representing the image to upload.
449456
Could be ``None`` to denote no avatar.
457+
banner: :class:`bytes`
458+
A :term:`py:bytes-like object` representing the image to upload.
459+
Could be ``None`` to denote no banner.
450460
451461
Returns
452462
-------
@@ -458,7 +468,7 @@ async def edit(
458468
HTTPException
459469
Editing your profile failed.
460470
InvalidArgument
461-
Wrong image format passed for ``avatar``.
471+
Wrong image format passed for ``avatar`` or ``banner``.
462472
"""
463473
payload: dict[str, Any] = {}
464474
if username is not MISSING:
@@ -469,6 +479,11 @@ async def edit(
469479
elif avatar is not MISSING:
470480
payload["avatar"] = _bytes_to_base64_data(avatar)
471481

482+
if banner is None:
483+
payload["banner"] = None
484+
elif banner is not MISSING:
485+
payload["banner"] = _bytes_to_base64_data(banner)
486+
472487
data: UserPayload = await self._state.http.edit_profile(payload)
473488
return ClientUser(state=self._state, data=data)
474489

0 commit comments

Comments
 (0)