-
-
Notifications
You must be signed in to change notification settings - Fork 482
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
Unable to connect to voice channel due to "list index out of range" error
Reproduction Steps
It occurs only rarely, so the pattern is unclear.
It depends on the data sent from the Discord server.
Minimal Reproducible Code
import discord
intents = discord.Intents.none()
intents.guilds = True
intents.message_content = True
intents.guild_messages = True
intents.voice_states = True
bot = discord.Bot(intents=intents)
@bot.event
async def on_message(message):
if message.content == "connect":
await message.author.voice.channel.connect()
bot.run("TOKEN")
Expected Results
Connected to voice channel
Actual Results
[DEBUG] discord.gateway: Voice websocket frame received: {'op': 8, 'd': {'v': 4, 'heartbeat_interval': 13750.0}}
[DEBUG] discord.gateway: Voice websocket frame received: {'op': 2, 'd': {'streams': [{'type': 'video', 'ssrc': 193186, 'rtx_ssrc': 193187, 'rid': '', 'quality': 0, 'active': False}], 'ssrc': 193185, 'port': 50002, 'modes': ['aead_aes256_gcm_rtpsize', 'aead_xchacha20_poly1305_rtpsize'], 'ip': '35.213.101.214', 'experiments': ['fixed_keyframe_interval']}}
[DEBUG] discord.gateway: received packet in initial_connection: b'(hidden)'
[DEBUG] discord.gateway: detected ip: (hidden) port: (hidden)
[DEBUG] discord.gateway: received supported encryption modes:
[ERROR] __main__: list index out of range
Traceback (most recent call last):
File "/home/ubuntu/test/vc_test.py", line xxx, in connect_vc
await target.connect(timeout=10, reconnect=True)
File "/usr/local/lib/python3.11/dist-packages/discord/abc.py", line 1994, in connect
await voice.connect(timeout=timeout, reconnect=reconnect)
File "/usr/local/lib/python3.11/dist-packages/discord/voice_client.py", line 404, in connect
self.ws = await self.connect_websocket()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/discord/voice_client.py", line 375, in connect_websocket
await ws.poll_event()
File "/usr/local/lib/python3.11/dist-packages/discord/gateway.py", line 945, in poll_event
await self.received_message(utils._from_json(msg.data))
File "/usr/local/lib/python3.11/dist-packages/discord/gateway.py", line 862, in received_message
await self.initial_connection(data)
File "/usr/local/lib/python3.11/dist-packages/discord/gateway.py", line 916, in initial_connection
mode = modes[0]
~~~~~^^^
IndexError: list index out of range
Intents
guilds, message_content, guild_messages, voice_states
System Information
- Python v3.11.11-final
- py-cord v2.6.1-final
- aiohttp v3.11.13
- system info: Linux 6.8.0-55-generic # 57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025
Checklist
- I have searched the open issues for duplicates.
- I have shown the entire traceback, if possible.
- I have removed my token from display, if visible.
Additional Context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working