From 3110b463ef014811e9d8efcb7b065c883eea6491 Mon Sep 17 00:00:00 2001 From: = <=> Date: Sun, 6 Apr 2025 12:53:12 +0700 Subject: [PATCH] Put the music into a diff process --- commands/fun.py | 11 +++++++++++ commands/voice.py | 27 +++++++++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 commands/fun.py diff --git a/commands/fun.py b/commands/fun.py new file mode 100644 index 0000000..11421da --- /dev/null +++ b/commands/fun.py @@ -0,0 +1,11 @@ +import nextcord +from nextcord.ext import commands + +class Fun(commands.Cog): + def __init__(self, bot): + self.client = bot + + # Add something here later cuz im lazy raaahhh + +def setup(bot): + bot.add_cog(Fun(bot)) \ No newline at end of file diff --git a/commands/voice.py b/commands/voice.py index a4956b7..41cb16c 100644 --- a/commands/voice.py +++ b/commands/voice.py @@ -55,19 +55,22 @@ 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.") + def Music(): + SquogVoiceClient = ctx.guild.voice_client + print(link) + SquogDownload.download(link) + 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}")) print(ctx.guild.voice_client.is_connected()) - SquogVoiceClient = ctx.guild.voice_client - print(link) - SquogDownload.download(link) - 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}")) + multiprocessing.Process(Music).start() + @commands.command(description="Stops the music in voice channel") async def stop(self, ctx: nextcord.Message):