Skip to content

Commit c1ec0b1

Browse files
authored
Merge branch 'Pycord-Development:master' into master
2 parents fe80915 + 548ca85 commit c1ec0b1

16 files changed

+97
-33
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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,36 @@ possible (see our [Version Guarantees] for more info).
1010

1111
These changes are available on the `master` branch, but have not yet been released.
1212

13+
### Added
14+
15+
- Added `banner` parameter to `ClientUser.edit`.
16+
([#2396](https://github.com/Pycord-Development/pycord/pull/2396))
17+
- Added `user` argument to `Paginator.edit`.
18+
([#2390](https://github.com/Pycord-Development/pycord/pull/2390))
19+
20+
### Fixed
21+
22+
- Fixed the type-hinting of `Member.move_to` and `Member.edit` to reflect actual
23+
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))
27+
- Fixed `Paginator.edit` to no longer set user to the bot.
28+
([#2390](https://github.com/Pycord-Development/pycord/pull/2390))
29+
- Fixed `NameError` in some instances of `Interaction`.
30+
([#2402](https://github.com/Pycord-Development/pycord/pull/2402))
31+
- Fixed the type-hinting of `ScheduledEvent.subscribers` to reflect actual behavior.
32+
([#2400](https://github.com/Pycord-Development/pycord/pull/2400))
33+
- Fixed `ScheduledEvent.subscribers` behavior with `limit=None`.
34+
([#2407](https://github.com/Pycord-Development/pycord/pull/2407))
35+
36+
### Changed
37+
38+
- Changed the type of `Guild.bitrate_limit` to `int`.
39+
([#2387](https://github.com/Pycord-Development/pycord/pull/2387))
40+
- HTTP requests that fail with a 503 status are now re-tried.
41+
([#2395](https://github.com/Pycord-Development/pycord/pull/2395))
42+
1343
## [2.5.0] - 2024-03-02
1444

1545
### Added

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/bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ async def sync_commands(
680680
register all commands.
681681
682682
By default, this coroutine is called inside the :func:`.on_connect` event. If you choose to override the
683-
:func:`.on_connect` event, then you should invoke this coroutine as well such as the follwing:
683+
:func:`.on_connect` event, then you should invoke this coroutine as well such as the following:
684684
685685
.. code-block:: python
686686

discord/ext/pages/pagination.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import discord
3030
from discord.ext.bridge import BridgeContext
3131
from discord.ext.commands import Context
32+
from discord.member import Member
33+
from discord.user import User
3234

3335
__all__ = (
3436
"PaginatorButton",
@@ -1035,6 +1037,7 @@ async def edit(
10351037
suppress: bool | None = None,
10361038
allowed_mentions: discord.AllowedMentions | None = None,
10371039
delete_after: float | None = None,
1040+
user: User | Member | None = None,
10381041
) -> discord.Message | None:
10391042
"""Edits an existing message to replace it with the paginator contents.
10401043
@@ -1060,6 +1063,8 @@ async def edit(
10601063
are used instead.
10611064
delete_after: Optional[:class:`float`]
10621065
If set, deletes the paginator after the specified time.
1066+
user: Optional[Union[:class:`~discord.User`, :class:`~discord.Member`]]
1067+
If set, changes the user that this paginator belongs to.
10631068
10641069
Returns
10651070
-------
@@ -1079,7 +1084,7 @@ async def edit(
10791084
if page_content.custom_view:
10801085
self.update_custom_view(page_content.custom_view)
10811086

1082-
self.user = message.author
1087+
self.user = user or self.user
10831088

10841089
try:
10851090
self.message = await message.edit(

discord/flags.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,11 @@ def voice_states(self):
830830
831831
- :attr:`VoiceChannel.members`
832832
- :attr:`VoiceChannel.voice_states`
833+
- :attr:`StageChannel.members`
834+
- :attr:`StageChannel.speakers`
835+
- :attr:`StageChannel.listeners`
836+
- :attr:`StageChannel.moderators`
837+
- :attr:`StageChannel.voice_states`
833838
- :attr:`Member.voice`
834839
835840
.. note::

discord/guild.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def _from_data(self, guild: GuildPayload) -> None:
539539
)
540540

541541
self.owner_id: int | None = utils._get_as_snowflake(guild, "owner_id")
542-
self.afk_channel: VocalGuildChannel | None = self.get_channel(
542+
self.afk_channel: VoiceChannel | None = self.get_channel(
543543
utils._get_as_snowflake(guild, "afk_channel_id")
544544
) # type: ignore
545545

@@ -823,14 +823,16 @@ def sticker_limit(self) -> int:
823823
)
824824

825825
@property
826-
def bitrate_limit(self) -> float:
826+
def bitrate_limit(self) -> int:
827827
"""The maximum bitrate for voice channels this guild can have."""
828828
vip_guild = (
829829
self._PREMIUM_GUILD_LIMITS[1].bitrate
830830
if "VIP_REGIONS" in self.features
831831
else 96e3
832832
)
833-
return max(vip_guild, self._PREMIUM_GUILD_LIMITS[self.premium_tier].bitrate)
833+
return int(
834+
max(vip_guild, self._PREMIUM_GUILD_LIMITS[self.premium_tier].bitrate)
835+
)
834836

835837
@property
836838
def filesize_limit(self) -> int:
@@ -3443,7 +3445,7 @@ async def change_voice_state(
34433445
34443446
Parameters
34453447
----------
3446-
channel: Optional[:class:`VoiceChannel`]
3448+
channel: Optional[Union[:class:`VoiceChannel`, :class:`StageChannel`]]
34473449
Channel the client wants to join. Use ``None`` to disconnect.
34483450
self_mute: :class:`bool`
34493451
Indicates if the client should be self-muted.

discord/http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ async def request(
357357

358358
continue
359359

360-
# we've received a 500, 502, or 504, unconditional retry
361-
if response.status in {500, 502, 504}:
360+
# we've received a 500, 502, 503, or 504, unconditional retry
361+
if response.status in {500, 502, 503, 504}:
362362
await asyncio.sleep(1 + tries * 2)
363363
continue
364364

discord/interactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from .errors import ClientException, InteractionResponded, InvalidArgument
3535
from .file import File
3636
from .flags import MessageFlags
37+
from .guild import Guild
3738
from .member import Member
3839
from .message import Attachment, Message
3940
from .monetization import Entitlement
@@ -69,7 +70,6 @@
6970
from .client import Client
7071
from .commands import OptionChoice
7172
from .embeds import Embed
72-
from .guild import Guild
7373
from .mentions import AllowedMentions
7474
from .state import ConnectionState
7575
from .threads import Thread

discord/iterators.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,10 @@ class ScheduledEventSubscribersIterator(_AsyncIterator[Union["User", "Member"]])
852852
def __init__(
853853
self,
854854
event: ScheduledEvent,
855-
limit: int,
855+
limit: int | None,
856856
with_member: bool = False,
857-
before: datetime.datetime | int = None,
858-
after: datetime.datetime | int = None,
857+
before: datetime.datetime | int | None = None,
858+
after: datetime.datetime | int | None = None,
859859
):
860860
if isinstance(before, datetime.datetime):
861861
before = Object(id=time_snowflake(before, high=False))
@@ -919,8 +919,14 @@ async def fill_subs(self):
919919
before=before,
920920
after=after,
921921
)
922-
if data:
923-
self.limit -= self.retrieve
922+
923+
data_length = len(data)
924+
if data_length < self.retrieve:
925+
self.limit = 0
926+
elif data_length > 0:
927+
if self.limit:
928+
self.limit -= self.retrieve
929+
self.after = Object(id=int(data[-1]["user_id"]))
924930

925931
for element in reversed(data):
926932
if "member" in element:

0 commit comments

Comments
 (0)