aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/music/play.py
diff options
context:
space:
mode:
authorSamlon <stankiewiczgracjan2019@gmail.com>2025-08-13 14:59:22 +0200
committerSamlon <stankiewiczgracjan2019@gmail.com>2025-08-13 14:59:22 +0200
commit8d0a52ab34563beab33be2dfb207da0e03a8fe32 (patch)
tree6d670fe2985259c9c2a69ce80f1b8a0bd1d16d6c /cogs/music/play.py
parentprevent discord from complaining (diff)
downloadsenator-sperma-8d0a52ab34563beab33be2dfb207da0e03a8fe32.tar.gz
senator-sperma-8d0a52ab34563beab33be2dfb207da0e03a8fe32.zip
prevent discord from complaining and bot does not leave vc after playing
Diffstat (limited to 'cogs/music/play.py')
-rw-r--r--cogs/music/play.py14
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 @@
1import asyncio
2import logging 1import logging
3
4import discord 2import discord
5import yt_dlp 3import yt_dlp
6from discord.ext import commands 4from 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: