From d4248bca50064d4435db713cf2c81a007d394c63 Mon Sep 17 00:00:00 2001 From: Samlon Date: Thu, 21 Aug 2025 12:22:00 +0200 Subject: small changes --- cogs/tts.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'cogs/tts.py') 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