ttstoy: add universal [p]disconnect command to leave VC

This commit is contained in:
2026-10-19 01:26:56 -05:00
parent 4023a8c072
commit 5dd4fb9ab4
+33
View File
@@ -3061,6 +3061,39 @@ class TtsToy(Cog):
except Exception:
log.exception("[Accessibility] voice reset error")
# ---------------------------------------------------------------------
# DISCONNECT FROM VOICE (universal)
# ---------------------------------------------------------------------
@commands.command(name="disconnect", aliases=["dc", "leave"])
@commands.guild_only()
async def disconnect_vc(self, ctx: commands.Context):
"""Disconnect the bot from voice chat."""
if not ctx.guild.me.voice:
return await ctx.send("Not in a voice channel.")
# Try lavalink player first (cleans up its queue/state).
try:
player = lavalink.get_player(ctx.guild.id)
player.queue.clear()
await player.stop()
await player.disconnect()
await ctx.send("Disconnected.")
return
except Exception:
pass
# Fallback: native discord.py voice client.
vc = ctx.guild.voice_client
if vc:
try:
await vc.disconnect(force=True)
await ctx.send("Disconnected.")
return
except Exception:
pass
await ctx.send("Disconnected.")
# ---------------------------------------------------------------------
# SPEAK COMMAND (JUST [p]tts)
# ---------------------------------------------------------------------