From 4c7a5225da6ff282fef4ad23df411e180d92cf78 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 7 Apr 2025 15:23:34 +0700 Subject: [PATCH] Put music loading in a different process again --- commands/fun.py | 1 + commands/voice.py | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/commands/fun.py b/commands/fun.py index db998ea..8d1efb8 100644 --- a/commands/fun.py +++ b/commands/fun.py @@ -9,6 +9,7 @@ class Fun(commands.Cog): @commands.command() async def boop(self, ctx: nextcord.Message, user: nextcord.User): await ctx.reply(f"{user.mention} shall get booped!", files=[nextcord.File("./images/boop.webp")]) + # Add something here later cuz im lazy raaahhh def setup(bot): diff --git a/commands/voice.py b/commands/voice.py index ebdeb95..8bcef06 100644 --- a/commands/voice.py +++ b/commands/voice.py @@ -55,19 +55,26 @@ class Voice(commands.Cog): return await ctx.reply("I'm not in a voice channel.") if ctx.guild.voice_client.is_playing(): return await ctx.reply("I'm already playing music.") - SquogVoiceClient = ctx.guild.voice_client - print(link) - SquogDownload.download(link) + # Extracting info for the filename SquogInfo = SquogDownload.extract_info(link, download=False) - SquogFinalName = SquogDownload.prepare_filename(SquogInfo) - SquogLength = SquogFinalName.__len__() - 4 - SquogExt = os.path.splitext(SquogFinalName) - print(SquogExt) - SquogLength = SquogFinalName.find(SquogExt[1]) + 1 - print(SquogLength) - SquogEvilFilename = f"{SquogFinalName[:SquogLength]}mp3" - SquogVoiceClient.play(nextcord.FFmpegPCMAudio(f"{SquogEvilFilename}")) + Embed = nextcord.Embed(title="Loading music", description=SquogDownload.prepare_filename(SquogInfo)) + # Notifying the user that music is getting started so they know its there + await ctx.reply(embed=Embed) + SquogVoiceClient = ctx.guild.voice_client + + def Test(): + SquogDownload.download(link) + SquogFinalName = SquogDownload.prepare_filename(SquogInfo) + SquogLength = SquogFinalName.__len__() - 4 + SquogExt = os.path.splitext(SquogFinalName) + print(SquogExt) + SquogLength = SquogFinalName.find(SquogExt[1]) + 1 + print(SquogLength) + SquogEvilFilename = f"{SquogFinalName[:SquogLength]}mp3" + SquogVoiceClient.play(nextcord.FFmpegPCMAudio(f"{SquogEvilFilename}")) + + multiprocessing.Process(target=Test).start() @commands.command(description="Stops the music in voice channel") async def stop(self, ctx: nextcord.Message):