Browse Source

Change Event to Future and add versionadded tag

pull/9842/head
Imayhaveborkedit 10 months ago
parent
commit
6f74fb7213
  1. 7
      discord/player.py
  2. 2
      discord/voice_client.py

7
discord/player.py

@ -718,7 +718,7 @@ class AudioPlayer(threading.Thread):
self._current_error: Optional[Exception] = None
self._lock: threading.Lock = threading.Lock()
self._end_async: asyncio.Event = asyncio.Event(loop=client.loop)
self._end_future = client.loop.create_future()
if after is not None and not callable(after):
raise TypeError('Expected a callable for the "after" parameter.')
@ -778,7 +778,7 @@ class AudioPlayer(threading.Thread):
finally:
self._call_after()
self._cleanup()
self.client.loop.call_soon_threadsafe(self._end_async.set)
self.client.loop.call_soon_threadsafe(self._end_future.set_result, self._current_error)
def _call_after(self) -> None:
error = self._current_error
@ -828,8 +828,7 @@ class AudioPlayer(threading.Thread):
self.resume(update_speaking=False)
async def wait_async(self) -> Optional[Exception]:
await self._end_async.wait()
return self._current_error
return await self._end_future
def _speak(self, speaking: SpeakingState) -> None:
try:

2
discord/voice_client.py

@ -543,6 +543,8 @@ class VoiceClient(VoiceProtocol):
Waits for the audio player to finish playback and returns any encountered error.
.. versionadded:: 2.4
Returns
--------
Optional[:class:`Exception`]

Loading…
Cancel
Save