From 62e75cd158a0a9c429412a4eeb7c57babbe9e48a Mon Sep 17 00:00:00 2001 From: 0xbyt4 <35742124+0xbyt4@users.noreply.github.com> Date: Wed, 11 Mar 2026 21:49:19 +0300 Subject: [PATCH] fix: skip duplicate TTS file attachment when bot is in Discord voice channel Override play_tts in DiscordAdapter to no-op when connected to a voice channel for the same guild. The gateway runner already plays TTS audio in the VC via play_in_voice_channel, so the base adapter's fallback to send_voice (file attachment) was causing double audio output. --- gateway/platforms/discord.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gateway/platforms/discord.py b/gateway/platforms/discord.py index d8bbb444..d10375e3 100644 --- a/gateway/platforms/discord.py +++ b/gateway/platforms/discord.py @@ -603,6 +603,23 @@ class DiscordAdapter(BasePlatformAdapter): msg = await channel.send(content=caption if caption else None, file=file) return SendResult(success=True, message_id=str(msg.id)) + async def play_tts( + self, + chat_id: str, + audio_path: str, + **kwargs, + ) -> SendResult: + """Play auto-TTS audio. + + When the bot is in a voice channel for this chat's guild, skip the + file attachment — the gateway runner plays audio in the VC instead. + """ + for gid, text_ch_id in self._voice_text_channels.items(): + if str(text_ch_id) == str(chat_id) and self.is_in_voice_channel(gid): + logger.debug("[%s] Skipping play_tts for %s — VC playback handled by runner", self.name, chat_id) + return SendResult(success=True) + return await self.send_voice(chat_id=chat_id, audio_path=audio_path, **kwargs) + async def send_voice( self, chat_id: str,