Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 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
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-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
2 changes: 1 addition & 1 deletion discord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@


from . import abc, opus, sinks, ui, utils
from ._voice_aliases import *
from .activity import *
from .appinfo import *
from .application_role_connection import *
Expand Down Expand Up @@ -72,7 +73,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
74 changes: 74 additions & 0 deletions discord/_voice_aliases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""
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:
from typing_extensions import deprecated

from discord.voice import VoiceClientC, 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

return VoiceClient(client, channel)

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

return VoiceProtocol(client, channel)
3 changes: 2 additions & 1 deletion discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from .role import Role
from .scheduled_events import ScheduledEvent
from .sticker import GuildSticker, StickerItem
from .voice_client import VoiceClient, VoiceProtocol
from .voice import VoiceClient, VoiceProtocol

__all__ = (
"Snowflake",
Expand Down Expand Up @@ -1966,6 +1966,7 @@ class Connectable(Protocol):

__slots__ = ()
_state: ConnectionState
id: int

def _get_voice_client_key(self) -> tuple[int, str]:
raise NotImplementedError
Expand Down
2 changes: 1 addition & 1 deletion discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,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
51 changes: 16 additions & 35 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 All @@ -51,7 +50,7 @@
from .invite import Invite
from .iterators import EntitlementIterator, GuildIterator
from .mentions import AllowedMentions
from .monetization import SKU, Entitlement
from .monetization import SKU
from .object import Object
from .soundboard import SoundboardSound
from .stage_instance import StageInstance
Expand All @@ -62,7 +61,7 @@
from .ui.view import View
from .user import ClientUser, User
from .utils import MISSING
from .voice_client import VoiceClient
from .voice import VoiceClient
from .webhook import Webhook
from .widget import Widget

Expand All @@ -75,7 +74,7 @@
from .poll import Poll
from .soundboard import SoundboardSound
from .ui.item import Item
from .voice_client import VoiceProtocol
from .voice import VoiceProtocol

__all__ = ("Client",)

Expand Down Expand Up @@ -807,7 +806,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 @@ -831,41 +835,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 @@ -48,7 +48,7 @@
from ..permissions import Permissions
from ..state import ConnectionState
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
Loading