aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cogs/ai.py1
-rw-r--r--cogs/voice.py60
-rw-r--r--requirements.txt88
3 files changed, 84 insertions, 65 deletions
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 @@
1import os 1import os
2 2
3import discord 3import discord
4import google.generativeai as genai
5from discord.ext import commands 4from discord.ext import commands
6import logging 5import logging
7import requests 6import 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 @@
1import discord
2from discord.ext import commands
3import logging
4import asyncio
5
6logger = logging.getLogger(__name__)
7
8class Voice(commands.Cog):
9 def __init__(self, bot):
10 self.bot = bot
11
12 async def ensure_voice_client(self, ctx):
13 """Ensure we have a valid voice client connection."""
14 if not ctx.author.voice or not ctx.author.voice.channel:
15 await ctx.send("You need to be in a voice channel first!")
16 return None
17
18 voice_client = discord.utils.get(self.bot.voice_clients, guild=ctx.guild)
19
20 # If no voice client exists, create one
21 if not voice_client or not voice_client.is_connected():
22 try:
23 voice_client = await ctx.author.voice.channel.connect(timeout=30.0, reconnect=True)
24 logger.info(f"Connected to voice channel: {ctx.author.voice.channel}")
25 except asyncio.TimeoutError:
26 await ctx.send("Connection to voice channel timed out.")
27 except discord.ClientException as e:
28 logger.error(f"Failed to connect to voice channel: {e}")
29 await ctx.send("Failed to connect to voice channel. Please try again.", ephemeral=True)
30 # If we're in a different channel, move to the user's channel
31 elif voice_client.channel != ctx.author.voice.channel:
32 try:
33 await voice_client.move_to(ctx.author.voice.channel)
34 logger.info(f"Moved to voice channel: {ctx.author.voice.channel}")
35 except asyncio.TimeoutError:
36 await ctx.send("Connection to voice channel timed out.")
37 except discord.ClientException as e:
38 logger.error(f"Failed to move to voice channel: {e}")
39 await ctx.send("Failed to move to your voice channel. Please try again.", ephemeral=True)
40
41 # Verify the connection is healthy
42 if not voice_client.is_connected():
43 try:
44 await voice_client.connect(reconnect=True, timeout=10.0)
45 except Exception as e:
46 logger.error(f"Failed to reconnect to voice: {e}")
47 await ctx.send("Failed to establish voice connection. Please try again.")
48 return None
49
50 async def connect(self, ctx):
51 """Connect to the user's voice channel with improved connection handling."""
52 voice_client = await self.ensure_voice_client(ctx)
53 if not voice_client:
54 return None
55
56 return voice_client
57
58
59def setup(bot):
60 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 @@
1aiohappyeyeballs==2.6.1 1aiohappyeyeballs==2.6.1
2aiohttp==3.12.15 2aiohttp==3.13.3
3aiosignal==1.4.0 3aiosignal==1.4.0
4annotated-types==0.7.0 4anyio==4.12.0
5anyio==4.11.0 5attrs==25.4.0
6apsw==3.50.4.0 6beautifulsoup4==4.14.3
7audioop-lts==0.2.2 7certifi==2025.11.12
8cachetools==6.2.0
9certifi==2025.8.3
10cffi==2.0.0 8cffi==2.0.0
11click==8.3.0 9charset-normalizer==3.4.4
12cryptography==46.0.1 10click==8.1.8
13cssselect==1.3.0 11dotenv==0.9.9
14ffmpeg-python==0.2.0 12ffmpeg==1.4
15frozenlist==1.7.0 13frozenlist==1.8.0
16future==1.0.0
17google-ai-generativelanguage==0.7.0
18google-api-core==2.25.1
19google-api-python-client==2.183.0
20google-auth==2.40.3
21google-auth-httplib2==0.2.0
22google-genai==1.38.0
23google-generativeai==0.8.5
24googleapis-common-protos==1.70.0
25grpcio==1.75.0
26grpcio-status==1.75.0
27gTTS==2.5.4 14gTTS==2.5.4
28h11==0.16.0 15h11==0.16.0
29httpcore==1.0.9 16httpcore==1.0.9
30httplib2==0.31.0
31httpx==0.28.1 17httpx==0.28.1
32idna==3.10 18idna==3.11
33incremental==24.7.2 19multidict==6.7.0
34jaraco.collections==5.2.1 20mutagen==1.47.0
35jaraco.functools==4.3.0 21propcache==0.4.1
36msgpack==1.1.1 22py-cord==2.7.0
37multidict==6.6.4
38path==17.1.1
39pdftotext==3.0.0
40propcache==0.3.2
41proto-plus==1.26.1
42protobuf==6.32.1
43psutil==7.1.0
44py-cord==2.6.1
45pyasn1==0.6.1
46pyasn1_modules==0.4.2
47pycparser==2.23 23pycparser==2.23
48pydantic==2.11.9 24PyNaCl==1.6.2
49pydantic_core==2.39.0 25python-dotenv==1.2.1
50PyGObject==3.54.2
51rapidfuzz==3.14
52PyNaCl==1.6.0
53PyOpenGL==3.1.10
54pyparsing==3.2.5
55python-dateutil==2.9.0.post0
56python-dotenv==1.1.1
57pytube==15.0.0 26pytube==15.0.0
58rsa==4.9.1 27RapidFuzz==3.14.3
59sniffio==1.3.1 28requests==2.32.5
60tbb==2022.2.0 29soupsieve==2.8.1
61tcmlib==1.4.0 30typing_extensions==4.15.0
62tenacity==9.1.2 31urllib3==2.6.2
63Twisted==25.5.0 32yarl==1.22.0
64txaio==25.6.1
65typing-inspection==0.4.1
66uritemplate==4.2.0
67websockets==15.0.1
68wsaccel==0.6.7
69yarl==1.20.1
70youtube-search-python==1.6.6 33youtube-search-python==1.6.6
71yt-dlp==2025.9.23 34yt-dlp==2025.12.8
72zeroconf==0.147.2
73zope.event==6.0
74zope.interface==8.0.1