Skip to content

Commit b27903a

Browse files
authored
Merge branch 'master' into app_emojis
Signed-off-by: UK <[email protected]>
2 parents 73d9336 + 9a83a2a commit b27903a

File tree

9 files changed

+32
-5
lines changed

9 files changed

+32
-5
lines changed

.github/workflows/todo-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: "Checkout Repository"
2424
uses: actions/checkout@v4
2525
- name: "Track TODO Action"
26-
uses: ribtoks/[email protected].12-beta
26+
uses: ribtoks/[email protected].13-beta
2727
with:
2828
TOKEN: ${{ secrets.GITHUB_TOKEN }}
2929
REPO: ${{ github.repository }}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.6.0
7+
rev: v5.0.0
88
hooks:
99
- id: trailing-whitespace
1010
exclude: \.(po|pot|yml|yaml)$

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ These changes are available on the `master` branch, but have not yet been releas
2626
([#2501](https://github.com/Pycord-Development/pycord/pull/2501))
2727
- Added `cache_app_emojis` parameter to `Client`.
2828
([#2501](https://github.com/Pycord-Development/pycord/pull/2501))
29+
- Added `elapsed` method to `VoiceClient`.
30+
([#2587](https://github.com/Pycord-Development/pycord/pull/2587/))
2931
- Added optional `filter` parameter to `utils.basic_autocomplete()`.
3032
([#2590](https://github.com/Pycord-Development/pycord/pull/2590))
3133

@@ -44,6 +46,8 @@ These changes are available on the `master` branch, but have not yet been releas
4446
- Fixed `Guild.create_test_entitlement()` and `User.create_test_entitlement()` using the
4547
guild/user ID instead of the application ID.
4648
([#2595](https://github.com/Pycord-Development/pycord/pull/2595))
49+
- Fixed commands with `BucketType.cagegory` cooldown causing issues in private channels.
50+
([#2603](https://github.com/Pycord-Development/pycord/pull/2603))
4751

4852
### Changed
4953

discord/ext/commands/cooldowns.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from collections import deque
3131
from typing import TYPE_CHECKING, Any, Callable, Deque, TypeVar
3232

33+
import discord.abc
3334
from discord.enums import Enum
3435

3536
from ...abc import PrivateChannel
@@ -69,7 +70,12 @@ def get_key(self, msg: Message) -> Any:
6970
elif self is BucketType.member:
7071
return (msg.guild and msg.guild.id), msg.author.id
7172
elif self is BucketType.category:
72-
return (msg.channel.category or msg.channel).id # type: ignore
73+
return (
74+
msg.channel.category.id
75+
if isinstance(msg.channel, discord.abc.GuildChannel)
76+
and msg.channel.category
77+
else msg.channel.id
78+
)
7379
elif self is BucketType.role:
7480
# we return the channel id of a private-channel as there are only roles in guilds
7581
# and that yields the same result as for a guild with only the @everyone role

discord/message.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,8 @@ async def edit(
15481548
15491549
Raises
15501550
------
1551+
NotFound
1552+
The message was not found.
15511553
HTTPException
15521554
Editing the message failed.
15531555
Forbidden

discord/player.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ def __init__(self, source: AudioSource, client: VoiceClient, *, after=None):
724724
self._current_error: Exception | None = None
725725
self._connected: threading.Event = client._connected
726726
self._lock: threading.Lock = threading.Lock()
727+
self._played_frames_offset: int = 0
727728

728729
if after is not None and not callable(after):
729730
raise TypeError('Expected a callable for the "after" parameter.')
@@ -751,10 +752,12 @@ def _do_run(self) -> None:
751752
# wait until we are connected
752753
self._connected.wait()
753754
# reset our internal data
755+
self._played_frames_offset += self.loops
754756
self.loops = 0
755757
self._start = time.perf_counter()
756758

757759
self.loops += 1
760+
758761
# Send the data read from the start of the function if it is not None
759762
if first_data is not None:
760763
data = first_data
@@ -809,6 +812,7 @@ def pause(self, *, update_speaking: bool = True) -> None:
809812
self._speak(False)
810813

811814
def resume(self, *, update_speaking: bool = True) -> None:
815+
self._played_frames_offset += self.loops
812816
self.loops = 0
813817
self._start = time.perf_counter()
814818
self._resumed.set()
@@ -834,3 +838,7 @@ def _speak(self, speaking: bool) -> None:
834838
)
835839
except Exception as e:
836840
_log.info("Speaking call in player failed: %s", e)
841+
842+
def played_frames(self) -> int:
843+
"""Gets the number of 20ms frames played since the start of the audio file."""
844+
return self._played_frames_offset + self.loops

discord/voice_client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from __future__ import annotations
4141

4242
import asyncio
43+
import datetime
4344
import logging
4445
import select
4546
import socket
@@ -988,3 +989,9 @@ def send_audio_packet(self, data: bytes, *, encode: bool = True) -> None:
988989
)
989990

990991
self.checked_add("timestamp", opus.Encoder.SAMPLES_PER_FRAME, 4294967295)
992+
993+
def elapsed(self) -> datetime.timedelta:
994+
"""Returns the elapsed time of the playing audio."""
995+
if self._player:
996+
return datetime.timedelta(milliseconds=self._player.played_frames() * 20)
997+
return datetime.timedelta()

docs/old_changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ Bug Fixes
625625
- Fix out of order files being sent in webhooks when there are 10 files.
626626
- |commands| Extensions that fail internally due to ImportError will no longer raise :exc:`~.ext.commands.ExtensionNotFound`. (:dpy-issue:`2244`, :dpy-issue:`2275`, :dpy-issue:`2291`)
627627
- |commands| Updating the :attr:`Paginator.suffix <.ext.commands.Paginator.suffix>` will not cause out of date calculations. (:dpy-issue:`2251`)
628-
- |commands| Allow converters from custom extension packages. (:dpy-issue:`2369`, :dpy-issue:`2374`)
628+
- |commands| Allow converters from custom extension packages. (:dpy-issue:`2369`, 2374)
629629
- |commands| Fix issue with paginator prefix being ``None`` causing empty pages. (:dpy-issue:`2471`)
630630
- |commands| :class:`~.commands.Greedy` now ignores parsing errors rather than propagating them.
631631
- |commands| :meth:`Command.can_run <.ext.commands.Command.can_run>` now checks whether a command is disabled.

requirements/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pytest-asyncio~=0.23.8
55
# pytest-order~=1.0.1
66
mypy~=1.11.2
77
coverage~=7.6
8-
pre-commit==3.8.0
8+
pre-commit==4.0.1
99
codespell==2.3.0
1010
bandit==1.7.10
1111
flake8==7.1.1

0 commit comments

Comments
 (0)