From 1dcdbe3cf03ff16b3ff2e2e6d572e0b3c72c18c0 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 19 Apr 2026 15:43:32 +0200 Subject: refactor: simplify cogs, reduce complexity - Remove unused imports and dead code - Cleaner error handling - Reduce cognitive complexity --- cogs/tts.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'cogs/tts.py') diff --git a/cogs/tts.py b/cogs/tts.py index 3dc4c09..68eb27f 100644 --- a/cogs/tts.py +++ b/cogs/tts.py @@ -54,19 +54,17 @@ class TTS(commands.Cog): if not voice_client: await ctx.respond("Failed to connect to voice channel", ephemeral=True) return - - # Play the TTS audio with volume adjustment + + if voice_client.is_playing(): + await ctx.respond("Audio is already playing, try again later", ephemeral=True) + return + audio_source = discord.FFmpegPCMAudio( temp_path, options=f'-filter:a "volume={volume}"' ) - voice_client.play(audio_source) logger.info(f"Playing TTS: {text}") - # Wait for the audio to finish playing - while voice_client.is_playing(): - await asyncio.sleep(0.1) - except Exception as e: logger.error(f"Error in voice channel handling: {e}") await ctx.respond("eror :c", ephemeral=True) -- cgit v1.2.3