From a7c330ab81e3d10f8a0c1a1af51db5721cc3a747 Mon Sep 17 00:00:00 2001 From: Samlon Date: Tue, 12 Aug 2025 21:11:23 +0200 Subject: rework ai and tts --- cogs/tts.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cogs/tts.py') diff --git a/cogs/tts.py b/cogs/tts.py index 8076a2d..07212ee 100644 --- a/cogs/tts.py +++ b/cogs/tts.py @@ -8,7 +8,6 @@ import logging logger = logging.getLogger(__name__) - class TTS(commands.Cog): def __init__(self, bot): self.bot = bot @@ -20,14 +19,17 @@ class TTS(commands.Cog): ): tts = gTTS(text=text, lang='pl') tts.save('tts.mp3') + if output == "file": await ctx.respond(file=discord.File('tts.mp3')) logger.info("TTS file sent") os.remove('tts.mp3') elif output == "vc": + # Defer the response to avoid "Bot did not respond" message + await ctx.defer() + # Check if the user is in a voice channel if not (ctx.author.voice and ctx.author.voice.channel): - await ctx.respond("Musisz być na kanale głosowym, aby odtworzyć TTS!", ephemeral=True) logger.info("User is not in a voice channel") os.remove('tts.mp3') return @@ -52,6 +54,5 @@ class TTS(commands.Cog): logger.info("Unknown playback method") os.remove('tts.mp3') - def setup(bot): bot.add_cog(TTS(bot)) -- cgit v1.2.3