diff options
Diffstat (limited to '')
| -rw-r--r-- | cogs/music/play.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cogs/music/play.py b/cogs/music/play.py index 5d82127..d902cdc 100644 --- a/cogs/music/play.py +++ b/cogs/music/play.py | |||
| @@ -1,10 +1,13 @@ | |||
| 1 | import asyncio | 1 | import asyncio |
| 2 | import logging | ||
| 2 | 3 | ||
| 3 | import discord | 4 | import discord |
| 4 | import yt_dlp | 5 | import yt_dlp |
| 5 | from discord.ext import commands | 6 | from discord.ext import commands |
| 6 | from youtubesearchpython import VideosSearch | 7 | from youtubesearchpython import VideosSearch |
| 7 | 8 | ||
| 9 | logger = logging.getLogger(__name__) | ||
| 10 | |||
| 8 | # Suppress noise about console usage from yt-dlp | 11 | # Suppress noise about console usage from yt-dlp |
| 9 | yt_dlp.utils.bug_reports_message = lambda: '' | 12 | yt_dlp.utils.bug_reports_message = lambda: '' |
| 10 | 13 | ||
| @@ -45,13 +48,13 @@ class Play(commands.Cog): | |||
| 45 | 48 | ||
| 46 | def after_playing(error): | 49 | def after_playing(error): |
| 47 | if error: | 50 | if error: |
| 48 | print(f'Player error: {error}') | 51 | logger.error(f'Player error: {error}') |
| 49 | coro = vc.disconnect() | 52 | coro = vc.disconnect() |
| 50 | fut = asyncio.run_coroutine_threadsafe(coro, self.bot.loop) | 53 | fut = asyncio.run_coroutine_threadsafe(coro, self.bot.loop) |
| 51 | try: | 54 | try: |
| 52 | fut.result() | 55 | fut.result() |
| 53 | except Exception as e: | 56 | except Exception as e: |
| 54 | print(f'Error disconnecting: {e}') | 57 | logger.error(f'Error disconnecting: {e}', exc_info=True) |
| 55 | 58 | ||
| 56 | source = discord.FFmpegPCMAudio(url2, **ffmpeg_options) | 59 | source = discord.FFmpegPCMAudio(url2, **ffmpeg_options) |
| 57 | vc.play(source, after=after_playing) | 60 | vc.play(source, after=after_playing) |
