From 431c52dd2acfa47cafc1a913696802fe5e1f1bf9 Mon Sep 17 00:00:00 2001 From: ionburger Date: Mon, 30 Jan 2023 12:47:27 -0700 Subject: [PATCH] yas --- py/cogs/voice.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/py/cogs/voice.py b/py/cogs/voice.py index e7148de..5ffd5e7 100644 --- a/py/cogs/voice.py +++ b/py/cogs/voice.py @@ -8,19 +8,21 @@ class Voice(commands.Cog): self.bot = bot def qhandler(error=None,self=None, ctx=None, st=None): + queue = (st.read("voice", "queue")).split("/./") try: - queue = (st.read("voice", "queue")).split("/./") queue.pop(0) - st.write("voice", "queue", "/./".join(queue)) - except ValueError: - ctx.voice_client.stop() - return + except: + pass + st.write("voice", "queue", "/./".join(queue)) ffmpeg_options = { 'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn' } - ctx.voice_client.play(discord.FFmpegPCMAudio(queue[0].get("url",None), **ffmpeg_options), after=self.qhandler(self, ctx)) - ctx.respond(f"Now playing: {queue[0].get('title',None)}") + if len(queue) > 0: + ctx.voice_client.play(discord.FFmpegPCMAudio(queue[0]), **ffmpeg_options, after=self.qhandler(self, ctx)) + ctx.respond(f"Now playing: {queue[0]}") + else: + ctx.voice_client.stop() @bridge.bridge_command() async def join(self, ctx): @@ -61,7 +63,7 @@ class Voice(commands.Cog): if ctx.voice_client is None: channel = ctx.author.voice.channel await channel.connect() - if link == "": + if link == "" and ctx.voice_client.is_paused(): ctx.voice_client.resume() return if ctx.voice_client.is_paused(): @@ -101,8 +103,9 @@ class Voice(commands.Cog): await ctx.respond(f"Now playing: {video_title}") else: queue = st.read("voice", "queue").split("/./") - queue.append(info_dict) + queue.append(info_dict.get("url",None)) st.write("voice", "queue", "/./".join(queue)) + await ctx.respond(f"Added to queue: {video_title}") @bridge.bridge_command(alias=["stop"]) async def pause(self, ctx):