diff --git a/discord/player.py b/discord/player.py index 5e44498f3..b1f02c3af 100644 --- a/discord/player.py +++ b/discord/player.py @@ -24,7 +24,6 @@ DEALINGS IN THE SOFTWARE. from __future__ import annotations import threading -import traceback import subprocess import audioop import asyncio @@ -709,14 +708,10 @@ class AudioPlayer(threading.Thread): try: self.after(error) except Exception as exc: - _log.exception('Calling the after function failed.') exc.__context__ = error - traceback.print_exception(type(exc), exc, exc.__traceback__) + _log.exception('Calling the after function failed.', exc_info=exc) elif error: - msg = f'Exception in voice thread {self.name}' - _log.exception(msg, exc_info=error) - print(msg, file=sys.stderr) - traceback.print_exception(type(error), error, error.__traceback__) + _log.exception('Exception in voice thread %s.', self.name, exc_info=error) def stop(self) -> None: self._end.set() diff --git a/discord/voice_client.py b/discord/voice_client.py index 63bcb87a2..b7c0eb0ad 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -587,7 +587,10 @@ class VoiceClient(VoiceProtocol): If an error happens while the audio player is running, the exception is caught and the audio player is then stopped. If no after callback is - passed, any caught exception will be displayed as if it were raised. + passed, any caught exception will be logged using the library logger. + + .. versionchanged:: 2.0 + Instead of writing to ``sys.stderr``, the library's logger is used. Parameters ----------- diff --git a/docs/migrating.rst b/docs/migrating.rst index 3cf5559b5..ad2ae254c 100644 --- a/docs/migrating.rst +++ b/docs/migrating.rst @@ -852,6 +852,7 @@ The library now provides a default logging configuration if using :meth:`Client. - :meth:`Client.on_error` - :meth:`discord.ext.tasks.Loop.error` - :meth:`discord.ext.commands.Bot.on_command_error` +- :meth:`VoiceClient.play` For more information, check :doc:`logging`.