diff --git a/wavelink/events.py b/wavelink/events.py index 85c7c0fa..feaac5e4 100644 --- a/wavelink/events.py +++ b/wavelink/events.py @@ -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 diff --git a/wavelink/node.py b/wavelink/node.py index 7bf4659d..a3c56dad 100644 --- a/wavelink/node.py +++ b/wavelink/node.py @@ -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 diff --git a/wavelink/websocket.py b/wavelink/websocket.py index 5048440e..051ead65 100644 --- a/wavelink/websocket.py +++ b/wavelink/websocket.py @@ -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: