devoxin / Lavalink.py

A wrapper for Lavalink in Python, which aims to be powerful and intuitive.
https://lavalink.readthedocs.io/
MIT License
223 stars 96 forks source link

KeyError with on_voice_state_update event #30

Closed Zenrac closed 6 years ago

Zenrac commented 6 years ago
Task exception was never retrieved
future: <Task finished coro=<WebSocket.listen() done, defined at C:\Users\Zenrac\AppData\Local\Programs\Python\Python36-32\lib\site-packages\lavalink\WebSocket.py:92> exception=KeyError('position',)>
Traceback (most recent call last):
  File "C:\Users\Zenrac\AppData\Local\Programs\Python\Python36-32\lib\site-packages\lavalink\WebSocket.py", line 130, in listen
    await self._lavalink.update_state(data)
  File "C:\Users\Zenrac\AppData\Local\Programs\Python\Python36-32\lib\site-packages\lavalink\Client.py", line 62, in update_state
    p.position = data['state']['position']
KeyError: 'position'

It seems to happen since I've added an on_voice_state_update event I don't really know how to repro

devoxin commented 6 years ago

Can you show your code?

Zenrac commented 6 years ago

I figured out how to repro it :

I've replaced the QueueEndEvent by the following code (in the V3 example) :

        elif isinstance(event, lavalink.Events.QueueEndEvent):
            player = event.player
            if not player.paused:
                await player.set_pause(True)  

In a way this is stupid to pause the player when no song are queued but it is not supposed to raise a KeyError

AndyTempel commented 6 years ago

Same issue here, no obvious error in custom event processing.

devoxin commented 6 years ago

Looks like Lavalink is possibly sending incomplete data.

Zenrac commented 6 years ago

Should be fixed with https://github.com/Devoxin/Lavalink.py/commit/7e42722e56f92cd3760de8ae07492842cefa27c8