Skip to content

Commit e58dd4d

Browse files
committed
Merge branch 'features/voice-receive'
2 parents ef9b598 + 740c41e commit e58dd4d

File tree

9 files changed

+912
-168
lines changed

9 files changed

+912
-168
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ docs/crowdin.py
1010
*.mp3
1111
*.m4a
1212
*.wav
13+
*.pcm
1314
*.png
1415
*.jpg
1516
*.flac
@@ -18,6 +19,8 @@ docs/crowdin.py
1819
.DS_Store
1920
.python-version
2021
__pycache__
21-
.vs/slnx.sqlite
22+
.vs/*
23+
.vscode/*
2224
env/
2325
build/
26+
test.py

discord/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
from .sticker import *
5858
from .stage_instance import *
5959
from .interactions import *
60+
from .sink import *
6061
from .components import *
6162
from .threads import *
6263
from .bot import *

discord/errors.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
'NoEntryPointError',
6161
'ExtensionFailed',
6262
'ExtensionNotFound',
63+
'RecordingException',
6364
)
6465

6566

@@ -269,6 +270,19 @@ def __init__(self, shard_id: Optional[int]):
269270
)
270271
super().__init__(msg % shard_id)
271272

273+
class RecordingException(ClientException):
274+
"""Exception that's thrown when there is an error while trying to record
275+
audio from a voice channel.
276+
277+
.. versionadded:: 2.0
278+
"""
279+
pass
280+
281+
class SinkException(ClientException):
282+
"""Raised when a Sink error occurs.
283+
284+
.. versionadded:: 2.0
285+
"""
272286

273287
class InteractionResponded(ClientException):
274288
"""Exception that's raised when sending another interaction response using

discord/gateway.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ def __init__(self, socket, loop, *, hook=None):
728728
self._keep_alive = None
729729
self._close_code = None
730730
self.secret_key = None
731+
self.ssrc_map = {}
731732
if hook:
732733
self._hook = hook
733734

@@ -839,6 +840,15 @@ async def received_message(self, msg):
839840
self._keep_alive = VoiceKeepAliveHandler(ws=self, interval=min(interval, 5.0))
840841
self._keep_alive.start()
841842

843+
elif op == self.SPEAKING:
844+
ssrc = data['ssrc']
845+
user = int(data['user_id'])
846+
speaking = data['speaking']
847+
if ssrc in self.ssrc_map:
848+
self.ssrc_map[ssrc]['speaking'] = speaking
849+
else:
850+
self.ssrc_map.update({ssrc: {'user_id': user, 'speaking': speaking}})
851+
842852
await self._hook(self, msg)
843853

844854
async def initial_connection(self, data):

0 commit comments

Comments
 (0)