Full support for changing nodes

This commit is contained in:
Tyler 2019-10-13 00:04:01 -04:00
parent ba383db391
commit ef903095c9
2 changed files with 6 additions and 0 deletions

View File

@ -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,

View File

@ -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)
}