From ef903095c9d8bd549787080e93775dbc310f897f Mon Sep 17 00:00:00 2001 From: Tyler Date: Sun, 13 Oct 2019 00:04:01 -0400 Subject: [PATCH] Full support for changing nodes --- node.go | 1 + player.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/node.go b/node.go index d91151f..cc09283 100644 --- a/node.go +++ b/node.go @@ -184,6 +184,7 @@ func (node *Node) CreatePlayer(guildID string, sessionID string, event VoiceServ player := &Player{ guildID: guildID, + sessionID: sessionID, manager: node.manager, node: node, handler: handler, diff --git a/player.go b/player.go index 1562c7b..73ed965 100644 --- a/player.go +++ b/player.go @@ -7,6 +7,7 @@ import ( // Player is a Lavalink player type Player struct { guildID string + sessionID string time int position int paused bool @@ -167,6 +168,8 @@ func (player *Player) UserLeave(userId string) error { // To move a player to a new Node, first player.Destroy() it, and then // create a new player on the new node. func (player *Player) Forward(sessionID string, event VoiceServerUpdate) error { + player.sessionID = sessionID + msg := voiceUpdateMessage{ Op: opVoiceUpdate, GuildID: player.guildID, @@ -182,6 +185,8 @@ func (player *Player) Forward(sessionID string, event VoiceServerUpdate) error { func (player *Player) ChangeNode(node *Node) error { player.node = node + player.Forward(player.sessionID, player.lastVoiceServerUpdate) + return player.PlayAt(player.track, player.position, 0) }