diff --git a/ttstoy/ttstoy.py b/ttstoy/ttstoy.py index b3c9761..5e96e34 100644 --- a/ttstoy/ttstoy.py +++ b/ttstoy/ttstoy.py @@ -24,7 +24,7 @@ import requests from redbot.core import commands, Config from redbot.core.bot import Red, cog_data_path from redbot.core.commands import Cog -from redbot.cogs.audio import Audio +import lavalink try: from .morshutalk_engine import Morshu @@ -2433,10 +2433,13 @@ class TtsToy(Cog): async with ctx.typing(): # Check if user is in a VC - we'll play there if so, but it's not required user_in_vc = ctx.author.voice and ctx.author.voice.channel - audio: Optional[Audio] = self.bot.get_cog("Audio") - if user_in_vc and audio and not ctx.guild.me.voice: - await ctx.invoke(audio.command_summon) + if user_in_vc and not ctx.guild.me.voice: + # Connect via the shared Lavalink client (owned by the YTAudio cog). + try: + await lavalink.connect(ctx.author.voice.channel) + except Exception: + log.exception("[TTS] Failed to connect to voice channel via Lavalink.") mode = await self._get_tts_mode() @@ -2903,9 +2906,8 @@ class TtsToy(Cog): return member = member_guild.get_member(user_id) - audio_cog: Optional[Audio] = self.bot.get_cog("Audio") - if not audio_cog: - log.warning("[WebUI] Audio cog not loaded - skipping VC playback") + if not lavalink.get_all_nodes(): + log.warning("[WebUI] Lavalink not connected - skipping VC playback") return text_channel = member_guild.system_channel or next( (c for c in member_guild.text_channels @@ -2915,7 +2917,7 @@ class TtsToy(Cog): log.warning("[WebUI] No text channel available for VC playback") return if not member_guild.me.voice or member_guild.me.voice.channel != member_vc: - await member_vc.connect() + await lavalink.connect(member_vc) class _FakeCtx: guild = member_guild