Skip to content

Commit

Permalink
Handle state updates internally
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxin committed Feb 25, 2018
1 parent c8d0ee1 commit c532a78
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions lavalink/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ async def on_socket_response(self, data):
else:
if int(data['d']['user_id']) != self.bot.user.id:
return
self.voice_state.update({
'sessionId': data['d']['session_id']
})

self.voice_state.update({'sessionId': data['d']['session_id']})

guild_id = int(data['d']['guild_id'])

if self.bot.lavalink.players[guild_id]:
self.bot.lavalink.players[guild_id].channel_id = data['d']['channel_id']

if {'op', 'guildId', 'sessionId', 'event'} == self.voice_state.keys():
await self.bot.lavalink.ws.send(**self.voice_state)
Expand Down
2 changes: 1 addition & 1 deletion lavalink/PlayerManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def find(self, predicate):

def find_all(self, predicate):
""" Returns a list of players based on the given filter predicate """
return list(filter(predicate, self._players))
return list(filter(predicate, self._players.values()))

def get(self, guild_id):
""" Returns a player from the cache, or creates one if it does not exist """
Expand Down
2 changes: 1 addition & 1 deletion lavalink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__author__ = 'Luke & William'
__license__ = 'MIT'
__copyright__ = 'Copyright 2018 Luke & William'
__version__ = '2.0.2.6'
__version__ = '2.0.2.7'

from .AudioTrack import *
from .Client import *
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
setup(
name='lavalink',
packages=['lavalink'],
version='2.0.2.6',
version='2.0.2.7',
description='A lavalink interface built for discord.py',
author='Luke, William',
author_email='[email protected]',
url='https://github.com/Devoxin/Lavalink.py',
download_url='https://github.com/Devoxin/Lavalink.py/archive/2.0.2.6.tar.gz',
download_url='https://github.com/Devoxin/Lavalink.py/archive/2.0.2.7.tar.gz',
keywords=['lavalink'],
)

0 comments on commit c532a78

Please sign in to comment.