Skip to content

Commit

Permalink
Add player to the WebsocketClosed event.
Browse files Browse the repository at this point in the history
  • Loading branch information
EvieePy committed Feb 5, 2020
1 parent 36de6a8 commit abba49e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion wavelink/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,14 @@ def __str__(self):
class WebsocketClosed:
"""Event dispatched when a player disconnects from a Guild.
:ivar player: The :class:`wavelink.player.Player` associated with the event.
:ivar reason: The reason the event was dispatched.
:ivar code: The websocket reason code.
:ivar guild_id: The guild ID associated with the disconnect.
"""

def __init__(self, reason: str, code: int, guild_id: int):
def __init__(self, player: Player, reason: str, code: int, guild_id: int):
self.player = player
self.reason = reason
self.code = code
self.guild_id = guild_id
3 changes: 1 addition & 2 deletions wavelink/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ def get_player(self, guild_id: int) -> Optional[Player]:
async def on_event(self, event):
"""Function which dispatches events when triggered on the Node."""
__log__.info(f'NODE | Event dispatched:: <{str(event)}> ({self.__repr__()})')
if not isinstance(event, WebsocketClosed):
await event.player.hook(event)
await event.player.hook(event)

if not self.hook:
return
Expand Down
2 changes: 1 addition & 1 deletion wavelink/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def _get_event(self, name: str, data) -> Union[TrackEnd, TrackException, TrackSt
elif name == 'TrackStuckEvent':
return TrackStuck(data['player'], data['track'], int(data['threshold']))
elif name == 'WebSocketClosedEvent':
return WebsocketClosed(data['reason'], data['code'], data['guildId'])
return WebsocketClosed(data['player'], data['reason'], data['code'], data['guildId'])

async def _send(self, **data):
if self.is_connected:
Expand Down

0 comments on commit abba49e

Please sign in to comment.