29 lines
928 B
Python
29 lines
928 B
Python
import discord
|
|
from bot import Groovy
|
|
import config
|
|
import help
|
|
|
|
client = Groovy(command_prefix=config.get_prefix(), intents=discord.Intents.all())
|
|
|
|
@client.event
|
|
async def on_voice_state_update(member, before, after):
|
|
"""Handle voice state changes - auto-disconnect when alone"""
|
|
if member == client.user:
|
|
return # ignore self actions
|
|
|
|
# get the vc
|
|
voice_client = discord.utils.get(client.voice_clients, guild=member.guild)
|
|
|
|
# if the bot is the only connected member, disconnect
|
|
if voice_client and len(voice_client.channel.members) == 1:
|
|
from cogs.music import queue
|
|
# Clean up the queue
|
|
await queue.clear(member.guild.id)
|
|
await queue.update_server(member.guild.id, False)
|
|
try:
|
|
await voice_client.disconnect(force=True)
|
|
except Exception as e:
|
|
print(f"Error auto-disconnecting: {e}")
|
|
|
|
client.run(config.get_login("live"))
|