Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
a98025a
first commit on voice fixes
DA-344 Aug 21, 2025
0ea2077
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 21, 2025
56caff5
things
DA-344 Aug 26, 2025
b27b438
merge upstream
DA-344 Aug 26, 2025
098a280
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 26, 2025
8a6ae39
finish voice things, start voice-recv things
DA-344 Aug 26, 2025
f231d72
missing imports
DA-344 Aug 26, 2025
24d2db0
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 26, 2025
63b4d85
protocols
DA-344 Aug 26, 2025
d7be710
Merge branch 'feat/voice-rewrite-and-fixes' of https://github.com/DA-…
DA-344 Aug 26, 2025
fe88ee8
recv
DA-344 Aug 26, 2025
726c8f9
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 26, 2025
fbab980
fix voice connection, now fix voice recording :sob:
DA-344 Aug 26, 2025
266591d
Merge branch 'feat/voice-rewrite-and-fixes' of https://github.com/DA-…
DA-344 Aug 26, 2025
870d135
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 26, 2025
73d5c6d
actually i did this for logging
DA-344 Aug 26, 2025
109a06c
merge upstream
DA-344 Aug 26, 2025
8f891a3
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 26, 2025
eaa3d77
use utils._get_as_snowflake and remove old code
DA-344 Aug 26, 2025
1a40295
Merge branch 'feat/voice-rewrite-and-fixes' of https://github.com/DA-…
DA-344 Aug 26, 2025
def162d
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 26, 2025
c81adf5
remove fmt:off references
DA-344 Aug 26, 2025
d5bae0d
Merge branch 'feat/voice-rewrite-and-fixes' of https://github.com/DA-…
DA-344 Aug 26, 2025
88175b6
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 26, 2025
753e11b
add voice to the packages
DA-344 Aug 26, 2025
51858b9
keep GuildVoiceState alias to VoiceState
DA-344 Aug 26, 2025
b414b5f
fix type annotation
DA-344 Aug 26, 2025
9030478
voice recv things
DA-344 Aug 27, 2025
0b7c147
refactor voice recv logic
DA-344 Aug 30, 2025
83036da
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 30, 2025
4277b49
document default handlers
DA-344 Aug 30, 2025
46978ec
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 30, 2025
6c124bf
fix await outside async
DA-344 Aug 30, 2025
b34c254
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 30, 2025
18ded59
name error
DA-344 Aug 30, 2025
6f03ace
fix dispatchs not working ig
DA-344 Aug 30, 2025
94d3082
fix voice recv things fuck
DA-344 Aug 30, 2025
fe8e602
try to fix things
DA-344 Aug 30, 2025
212ce1d
voice recv is no longer funny
DA-344 Aug 31, 2025
628d5f6
merge master
DA-344 Aug 31, 2025
109d27c
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 31, 2025
a0f2a99
Merge branch 'master' of https://github.com/Pycord-Development/pycord…
DA-344 Sep 8, 2025
8304dba
add first pass to implement dave
DA-344 Sep 9, 2025
74d6590
yay voice recv
DA-344 Sep 11, 2025
60658bb
more voice recv
DA-344 Sep 12, 2025
d44f192
docs actions
DA-344 Sep 12, 2025
135550f
errors yay
DA-344 Sep 12, 2025
a324844
okay this needs fixing
DA-344 Sep 12, 2025
805d055
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 12, 2025
a49cddf
voice changes
DA-344 Jan 9, 2026
bcc841d
split voice connect from recv
DA-344 Feb 26, 2026
8c3ce89
some type fixes
DA-344 Feb 26, 2026
58bf955
remove unused imports
DA-344 Feb 26, 2026
c4a7cd7
merge master
DA-344 Feb 26, 2026
cd8f108
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 26, 2026
6897f44
some more type fixes and warning for recv
DA-344 Mar 3, 2026
78e44c9
chore: merge upstream
DA-344 Mar 3, 2026
740d822
chore: merge master
DA-344 Mar 3, 2026
be86c86
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 3, 2026
4f6040f
fix sinks docs
DA-344 Mar 3, 2026
a9e679c
Merge branch 'feat/voice-rewrite-and-fixes' of https://github.com/DA-…
DA-344 Mar 3, 2026
27da98c
fix docs
DA-344 Mar 3, 2026
bf18aba
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 3, 2026
5c98cdb
idk what happened here
DA-344 Mar 3, 2026
a55b01c
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 3, 2026
e9ec992
maybe fix circular
DA-344 Mar 3, 2026
b50761e
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 3, 2026
54db8bd
disliking docs atp
DA-344 Mar 3, 2026
8f99e4e
add voice to docs requirements
DA-344 Mar 3, 2026
23e474f
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 3, 2026
fe6e38c
add voice to docs reqs
DA-344 Mar 3, 2026
b4f9479
add voice to tests
DA-344 Mar 3, 2026
2189888
type fixes
DA-344 Mar 3, 2026
8ee5aec
remove undefined names from __all__
DA-344 Mar 3, 2026
48e23f2
add davey try/except imports and warn on init
DA-344 Mar 4, 2026
5d1244e
emit davey warning on discord.Client
DA-344 Mar 4, 2026
1ee4a1e
fix tox tests
DA-344 Mar 4, 2026
0f59da6
Merge branch 'master' into feat/voice-rewrite-and-fixes
DA-344 Mar 4, 2026
68e0eeb
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 4, 2026
9c5323c
fix VoiceClient & VoiceProtocol docs
DA-344 Mar 4, 2026
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
2 changes: 1 addition & 1 deletion .github/workflows/docs-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install -U pip
pip install ".[docs]"
pip install ".[docs,voice]"
- name: "Check Links"
if: ${{ github.event_name == 'schedule' || inputs.with_linkcheck }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-json-export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
id: install-deps
run: |
python -m pip install -U pip
pip install ".[docs]"
pip install ".[docs,voice]"
pip install beautifulsoup4
- name: Build Sphinx HTML docs
id: build-sphinx
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lib-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install . --group dev
pip install .[voice]
- name: "Run tests"
run: tox
Expand Down
1 change: 1 addition & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ python:
path: .
extra_requirements:
- docs
- voice
4 changes: 2 additions & 2 deletions discord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
# isort: on


from . import abc, opus, sinks, ui, utils
from . import abc, opus, sinks, ui, utils, voice
from ._voice_aliases import *
from .activity import *
from .appinfo import *
from .application_role_connection import *
Expand Down Expand Up @@ -74,7 +75,6 @@
from .template import *
from .threads import *
from .user import *
from .voice_client import *
from .webhook import *
from .welcome_screen import *
from .widget import *
Expand Down
75 changes: 75 additions & 0 deletions discord/_voice_aliases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""
The MIT License (MIT)

Copyright (c) 2015-2021 Rapptz
Copyright (c) 2021-present Pycord Development

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""

from __future__ import annotations

from typing import TYPE_CHECKING

from .utils import deprecated

"""
since discord.voice raises an error when importing it without having the
required package (ie davey) installed, we can't import it in __init__ because
that would break the whole library, that is why this file is here.

the error would still be raised, but at least here we have more freedom on how we are typing it
"""

__all__ = ("VoiceProtocol", "VoiceClient")


if TYPE_CHECKING:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this could just import inside the method. Would be clearer imo ? Wdyt

from typing_extensions import deprecated

from discord.voice import VoiceClient as VoiceClientC
from discord.voice import VoiceProtocol as VoiceProtocolC

@deprecated(
"discord.VoiceClient is deprecated in favour "
"of discord.voice.VoiceClient since 2.7 and "
"will be removed in 3.0",
)
def VoiceClient(client, channel) -> VoiceClientC: ...

@deprecated(
"discord.VoiceProtocol is deprecated in favour "
"of discord.voice.VoiceProtocol since 2.7 and "
"will be removed in 3.0",
)
def VoiceProtocol(client, channel) -> VoiceProtocolC: ...

else:

@deprecated("discord.VoiceClient", "discord.voice.VoiceClient", "2.7", "3.0")
def VoiceClient(client, channel):
from discord.voice import VoiceClient as VoiceClientC

return VoiceClientC(client, channel)

@deprecated("discord.VoiceProtocol", "discord.voice.VoiceProtocol", "2.7", "3.0")
def VoiceProtocol(client, channel):
from discord.voice import VoiceProtocol as VoiceProtocolC

return VoiceProtocolC(client, channel)
20 changes: 16 additions & 4 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
from .scheduled_events import ScheduledEvent
from .sticker import GuildSticker, StickerItem
from .utils import warn_deprecated
from .voice_client import VoiceClient, VoiceProtocol

__all__ = (
"Snowflake",
Expand All @@ -69,8 +68,6 @@
"Mentionable",
)

T = TypeVar("T", bound=VoiceProtocol)

if TYPE_CHECKING:
from datetime import datetime

Expand Down Expand Up @@ -106,6 +103,10 @@
MessageableChannel = Union[PartialMessageableChannel, GroupChannel]
SnowflakeTime = Union["Snowflake", datetime]

from .voice import VoiceClient, VoiceProtocol

T = TypeVar("T", bound=VoiceProtocol)

MISSING = utils.MISSING


Expand Down Expand Up @@ -2003,6 +2004,7 @@ class Connectable(Protocol):

__slots__ = ()
_state: ConnectionState
id: int

def _get_voice_client_key(self) -> tuple[int, str]:
raise NotImplementedError
Expand All @@ -2015,7 +2017,7 @@ async def connect(
*,
timeout: float = 60.0,
reconnect: bool = True,
cls: Callable[[Client, Connectable], T] = VoiceClient,
cls: Callable[[Client, Connectable], T] = MISSING,
) -> T:
"""|coro|

Expand Down Expand Up @@ -2051,6 +2053,16 @@ async def connect(
The opus library has not been loaded.
"""

# import directly from _types so if the user does not have davey
# it won't error here
from .voice._types import VoiceProtocol

if cls is MISSING:
# if the user passes no cls, then actually import VoiceClient
from .voice import VoiceClient

cls = VoiceClient # pyright: ignore[reportAssignmentType]

key_id, _ = self._get_voice_client_key()
state = self._state

Expand Down
2 changes: 1 addition & 1 deletion discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ def _update(
self, guild: Guild, data: VoiceChannelPayload | StageChannelPayload
) -> None:
# This data will always exist
self.guild = guild
self.guild: Guild = guild
self.name: str = data["name"]
self.category_id: int | None = utils._get_as_snowflake(data, "parent_id")

Expand Down
55 changes: 18 additions & 37 deletions discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import asyncio
import logging
import signal
import sys
import traceback
from types import TracebackType
Expand Down Expand Up @@ -71,23 +70,20 @@
from .ui.view import BaseView
from .user import ClientUser, User
from .utils import _D, _FETCHABLE, MISSING
from .voice_client import VoiceClient
from .voice import VoiceClient, VoiceProtocol
from .webhook import Webhook
from .widget import Widget

if TYPE_CHECKING:
from .abc import GuildChannel, PrivateChannel, Snowflake, SnowflakeTime
from .channel import (
DMChannel,
)
from .channel import DMChannel
from .interactions import Interaction
from .member import Member
from .message import Message
from .poll import Poll
from .soundboard import SoundboardSound
from .threads import Thread
from .ui.item import ViewItem
from .voice_client import VoiceProtocol

__all__ = ("Client",)

Expand Down Expand Up @@ -285,6 +281,9 @@ def __init__(
if VoiceClient.warn_nacl:
VoiceClient.warn_nacl = False
_log.warning("PyNaCl is not installed, voice will NOT be supported")
if VoiceClient.warn_davey:
VoiceClient.warn_davey = False
_log.warning("davey is not installed, voice will NOT be supported")

# Used to hard-reference tasks so they don't get garbage collected (discarded with done_callbacks)
self._tasks = set()
Expand Down Expand Up @@ -823,7 +822,12 @@ async def start(self, token: str, *, reconnect: bool = True) -> None:
await self.login(token)
await self.connect(reconnect=reconnect)

def run(self, *args: Any, **kwargs: Any) -> None:
def run(
self,
token: str,
*,
reconnect: bool = True,
) -> None:
"""A blocking call that abstracts away the event loop
initialisation from you.

Expand All @@ -847,41 +851,18 @@ def run(self, *args: Any, **kwargs: Any) -> None:
is blocking. That means that registration of events or anything being
called after this function call will not execute until it returns.
"""
loop = self.loop

try:
loop.add_signal_handler(signal.SIGINT, loop.stop)
loop.add_signal_handler(signal.SIGTERM, loop.stop)
except (NotImplementedError, RuntimeError):
pass

async def runner():
try:
await self.start(*args, **kwargs)
finally:
if not self.is_closed():
await self.close()
async with self:
await self.start(token, reconnect=reconnect)

def stop_loop_on_completion(f):
loop.stop()

future = asyncio.ensure_future(runner(), loop=loop)
future.add_done_callback(stop_loop_on_completion)
try:
loop.run_forever()
asyncio.run(runner())
except KeyboardInterrupt:
_log.info("Received signal to terminate bot and event loop.")
finally:
future.remove_done_callback(stop_loop_on_completion)
_log.info("Cleaning up tasks.")
_cleanup_loop(loop)

if not future.cancelled():
try:
return future.result()
except KeyboardInterrupt:
# I am unsure why this gets raised here but suppress it anyway
return None
# nothing to do here
# `asyncio.run` handles the loop cleanup
# and `self.start` closes all sockets and the HTTPClient instance.
return

# properties

Expand Down
2 changes: 1 addition & 1 deletion discord/commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
from ..state import ConnectionState
from ..ui import BaseView
from ..user import User
from ..voice_client import VoiceClient
from ..voice import VoiceClient
from ..webhook import WebhookMessage
from .core import ApplicationCommand, Option

Expand Down
2 changes: 1 addition & 1 deletion discord/ext/commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from discord.member import Member
from discord.state import ConnectionState
from discord.user import ClientUser, User
from discord.voice_client import VoiceProtocol
from discord.voice import VoiceProtocol

from .bot import AutoShardedBot, Bot
from .cog import Cog
Expand Down
Loading