From d4248bca50064d4435db713cf2c81a007d394c63 Mon Sep 17 00:00:00 2001 From: Samlon Date: Thu, 21 Aug 2025 12:22:00 +0200 Subject: small changes --- cogs/music/join.py | 2 +- cogs/music/stop.py | 2 +- cogs/tts.py | 10 ++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cogs/music/join.py b/cogs/music/join.py index 47c746f..a68282c 100644 --- a/cogs/music/join.py +++ b/cogs/music/join.py @@ -14,7 +14,7 @@ class Join(commands.Cog): channel = ctx.author.voice.channel await channel.connect() await ctx.respond(content="\u200b", ephemeral=True) - await ctx.interaction.delete_original_message() + await ctx.interaction.delete_original_response() logger.info("Bot connected to voice channel") diff --git a/cogs/music/stop.py b/cogs/music/stop.py index 5713c81..e04370e 100644 --- a/cogs/music/stop.py +++ b/cogs/music/stop.py @@ -12,7 +12,7 @@ class Stop(commands.Cog): @commands.slash_command(name="stop", description="stopuj bota") async def stop(self, ctx): await ctx.respond(content="\u200b", ephemeral=True) - await ctx.interaction.delete_original_message() + await ctx.interaction.delete_original_response() await ctx.voice_client.disconnect() logger.info("Bot disconnected from voice channel") diff --git a/cogs/tts.py b/cogs/tts.py index 7461a1f..74fc12c 100644 --- a/cogs/tts.py +++ b/cogs/tts.py @@ -17,6 +17,7 @@ class TTS(commands.Cog): text: str = discord.Option(str, "Tekst do przeczytania", required=True), output: str = discord.Option(str, "Wybierz sposób odtwarzania", choices=["file", "vc"], default="vc") ): + await ctx.defer() tts = gTTS(text=text, lang='pl') tts.save('tts.mp3') @@ -29,11 +30,11 @@ class TTS(commands.Cog): if output == "file": await ctx.respond(file=discord.File('tts.mp3')) - logger.info("TTS file sent") + logger.info(f"sent {text}") os.remove('tts.mp3') elif output == "vc": await ctx.respond(content="\u200b", ephemeral=True) - await ctx.interaction.delete_original_message() + await ctx.interaction.delete_original_response() # Check if the user is in a voice channel if not (ctx.author.voice and ctx.author.voice.channel): @@ -50,11 +51,8 @@ class TTS(commands.Cog): # Play the TTS audio if not voice_client.is_playing(): audio_source = discord.FFmpegPCMAudio('tts.mp3', options=f'-filter:a "volume={volume}"') - logger.info("TTS audio played") + logger.info(f"playing {text}") voice_client.play(audio_source) - # Wait for playback to finish - while voice_client.is_playing(): - await discord.utils.sleep_until(datetime.datetime.now() + datetime.timedelta(seconds=1)) os.remove('tts.mp3') else: await ctx.respond("Nieznany sposób odtwarzania.", ephemeral=True) -- cgit v1.2.3