fixed youtube's api interaction, fixed discord connection handshake errors

This commit is contained in:
2025-11-27 12:46:46 +00:00
parent 669e9c19fc
commit c7e033acb6
6 changed files with 217 additions and 79 deletions

15
main.py
View File

@@ -1,5 +1,4 @@
import discord
from discord.ext import tasks
from bot import Astro
import config
import help
@@ -9,14 +8,22 @@ client.help_command = help.AstroHelp()
@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
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, leave
# if the bot is the only connected member, disconnect
if voice_client and len(voice_client.channel.members) == 1:
await voice_client.disconnect()
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"))