Full support for changing nodes
This commit is contained in:
parent
ba383db391
commit
ef903095c9
1
node.go
1
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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue