From 270348cab5b7b20c25e300fa116d3fc79ef8452a Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 3 Jan 2026 21:01:18 +0100 Subject: bumped requirements --- cogs/ai.py | 1 - cogs/voice.py | 60 ++++++++++++++++++++++++++++++++++++++ requirements.txt | 88 ++++++++++++++++---------------------------------------- 3 files changed, 84 insertions(+), 65 deletions(-) create mode 100644 cogs/voice.py diff --git a/cogs/ai.py b/cogs/ai.py index 31e384d..984e5f7 100644 --- a/cogs/ai.py +++ b/cogs/ai.py @@ -1,7 +1,6 @@ import os import discord -import google.generativeai as genai from discord.ext import commands import logging import requests diff --git a/cogs/voice.py b/cogs/voice.py new file mode 100644 index 0000000..600a7eb --- /dev/null +++ b/cogs/voice.py @@ -0,0 +1,60 @@ +import discord +from discord.ext import commands +import logging +import asyncio + +logger = logging.getLogger(__name__) + +class Voice(commands.Cog): + def __init__(self, bot): + self.bot = bot + + async def ensure_voice_client(self, ctx): + """Ensure we have a valid voice client connection.""" + if not ctx.author.voice or not ctx.author.voice.channel: + await ctx.send("You need to be in a voice channel first!") + return None + + voice_client = discord.utils.get(self.bot.voice_clients, guild=ctx.guild) + + # If no voice client exists, create one + if not voice_client or not voice_client.is_connected(): + try: + voice_client = await ctx.author.voice.channel.connect(timeout=30.0, reconnect=True) + logger.info(f"Connected to voice channel: {ctx.author.voice.channel}") + except asyncio.TimeoutError: + await ctx.send("Connection to voice channel timed out.") + except discord.ClientException as e: + logger.error(f"Failed to connect to voice channel: {e}") + await ctx.send("Failed to connect to voice channel. Please try again.", ephemeral=True) + # If we're in a different channel, move to the user's channel + elif voice_client.channel != ctx.author.voice.channel: + try: + await voice_client.move_to(ctx.author.voice.channel) + logger.info(f"Moved to voice channel: {ctx.author.voice.channel}") + except asyncio.TimeoutError: + await ctx.send("Connection to voice channel timed out.") + except discord.ClientException as e: + logger.error(f"Failed to move to voice channel: {e}") + await ctx.send("Failed to move to your voice channel. Please try again.", ephemeral=True) + + # Verify the connection is healthy + if not voice_client.is_connected(): + try: + await voice_client.connect(reconnect=True, timeout=10.0) + except Exception as e: + logger.error(f"Failed to reconnect to voice: {e}") + await ctx.send("Failed to establish voice connection. Please try again.") + return None + + async def connect(self, ctx): + """Connect to the user's voice channel with improved connection handling.""" + voice_client = await self.ensure_voice_client(ctx) + if not voice_client: + return None + + return voice_client + + +def setup(bot): + bot.add_cog(Voice(bot)) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 1207ad7..958bc7d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,74 +1,34 @@ aiohappyeyeballs==2.6.1 -aiohttp==3.12.15 +aiohttp==3.13.3 aiosignal==1.4.0 -annotated-types==0.7.0 -anyio==4.11.0 -apsw==3.50.4.0 -audioop-lts==0.2.2 -cachetools==6.2.0 -certifi==2025.8.3 +anyio==4.12.0 +attrs==25.4.0 +beautifulsoup4==4.14.3 +certifi==2025.11.12 cffi==2.0.0 -click==8.3.0 -cryptography==46.0.1 -cssselect==1.3.0 -ffmpeg-python==0.2.0 -frozenlist==1.7.0 -future==1.0.0 -google-ai-generativelanguage==0.7.0 -google-api-core==2.25.1 -google-api-python-client==2.183.0 -google-auth==2.40.3 -google-auth-httplib2==0.2.0 -google-genai==1.38.0 -google-generativeai==0.8.5 -googleapis-common-protos==1.70.0 -grpcio==1.75.0 -grpcio-status==1.75.0 +charset-normalizer==3.4.4 +click==8.1.8 +dotenv==0.9.9 +ffmpeg==1.4 +frozenlist==1.8.0 gTTS==2.5.4 h11==0.16.0 httpcore==1.0.9 -httplib2==0.31.0 httpx==0.28.1 -idna==3.10 -incremental==24.7.2 -jaraco.collections==5.2.1 -jaraco.functools==4.3.0 -msgpack==1.1.1 -multidict==6.6.4 -path==17.1.1 -pdftotext==3.0.0 -propcache==0.3.2 -proto-plus==1.26.1 -protobuf==6.32.1 -psutil==7.1.0 -py-cord==2.6.1 -pyasn1==0.6.1 -pyasn1_modules==0.4.2 +idna==3.11 +multidict==6.7.0 +mutagen==1.47.0 +propcache==0.4.1 +py-cord==2.7.0 pycparser==2.23 -pydantic==2.11.9 -pydantic_core==2.39.0 -PyGObject==3.54.2 -rapidfuzz==3.14 -PyNaCl==1.6.0 -PyOpenGL==3.1.10 -pyparsing==3.2.5 -python-dateutil==2.9.0.post0 -python-dotenv==1.1.1 +PyNaCl==1.6.2 +python-dotenv==1.2.1 pytube==15.0.0 -rsa==4.9.1 -sniffio==1.3.1 -tbb==2022.2.0 -tcmlib==1.4.0 -tenacity==9.1.2 -Twisted==25.5.0 -txaio==25.6.1 -typing-inspection==0.4.1 -uritemplate==4.2.0 -websockets==15.0.1 -wsaccel==0.6.7 -yarl==1.20.1 +RapidFuzz==3.14.3 +requests==2.32.5 +soupsieve==2.8.1 +typing_extensions==4.15.0 +urllib3==2.6.2 +yarl==1.22.0 youtube-search-python==1.6.6 -yt-dlp==2025.9.23 -zeroconf==0.147.2 -zope.event==6.0 -zope.interface==8.0.1 +yt-dlp==2025.12.8 -- cgit v1.2.3