diff options
Diffstat (limited to 'cogs/music/play.py')
| -rw-r--r-- | cogs/music/play.py | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/cogs/music/play.py b/cogs/music/play.py index cf04ded..2314545 100644 --- a/cogs/music/play.py +++ b/cogs/music/play.py | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | import asyncio | ||
| 2 | import logging | 1 | import logging |
| 3 | |||
| 4 | import discord | 2 | import discord |
| 5 | import yt_dlp | 3 | import yt_dlp |
| 6 | from discord.ext import commands | 4 | from discord.ext import commands |
| @@ -46,18 +44,8 @@ class Play(commands.Cog): | |||
| 46 | 'options': '-vn' | 44 | 'options': '-vn' |
| 47 | } | 45 | } |
| 48 | 46 | ||
| 49 | def after_playing(error): | ||
| 50 | if error: | ||
| 51 | logger.error(f'Player error: {error}') | ||
| 52 | coro = vc.disconnect() | ||
| 53 | fut = asyncio.run_coroutine_threadsafe(coro, self.bot.loop) | ||
| 54 | try: | ||
| 55 | fut.result() | ||
| 56 | except Exception as e: | ||
| 57 | logger.error(f'Error disconnecting: {e}', exc_info=True) | ||
| 58 | |||
| 59 | source = discord.FFmpegPCMAudio(url2, **ffmpeg_options) | 47 | source = discord.FFmpegPCMAudio(url2, **ffmpeg_options) |
| 60 | vc.play(source, after=after_playing) | 48 | vc.play(source) |
| 61 | await ctx.followup.send(f"gra: {title}") | 49 | await ctx.followup.send(f"gra: {title}") |
| 62 | logger.info(f"Playing: {title}") | 50 | logger.info(f"Playing: {title}") |
| 63 | except Exception as e: | 51 | except Exception as e: |
