feature: add volume cache to player
This commit is contained in:
parent
cfb1661b64
commit
2fd6d25b7b
1
node.go
1
node.go
|
@ -158,6 +158,7 @@ func (node *Node) CreatePlayer(guildID string, sessionID string, event VoiceServ
|
||||||
manager: node.manager,
|
manager: node.manager,
|
||||||
node: node,
|
node: node,
|
||||||
handler: handler,
|
handler: handler,
|
||||||
|
vol: 100,
|
||||||
}
|
}
|
||||||
node.manager.players[guildID] = player
|
node.manager.players[guildID] = player
|
||||||
return player, nil
|
return player, nil
|
||||||
|
|
|
@ -13,6 +13,7 @@ type Player struct {
|
||||||
time int
|
time int
|
||||||
position int
|
position int
|
||||||
paused bool
|
paused bool
|
||||||
|
vol int
|
||||||
manager *Lavalink
|
manager *Lavalink
|
||||||
node *Node
|
node *Node
|
||||||
handler EventHandler
|
handler EventHandler
|
||||||
|
@ -111,6 +112,8 @@ func (player *Player) Volume(volume int) error {
|
||||||
return errVolumeOutOfRange
|
return errVolumeOutOfRange
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.vol = volume
|
||||||
|
|
||||||
msg := message{
|
msg := message{
|
||||||
Op: opVolume,
|
Op: opVolume,
|
||||||
GuildID: player.guildID,
|
GuildID: player.guildID,
|
||||||
|
@ -124,6 +127,11 @@ func (player *Player) Volume(volume int) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetVolume gets the player's volume level
|
||||||
|
func (player *Player) GetVolume() int {
|
||||||
|
return player.vol
|
||||||
|
}
|
||||||
|
|
||||||
// Forward will forward a new VOICE_SERVER_UPDATE to a Lavalink node for
|
// Forward will forward a new VOICE_SERVER_UPDATE to a Lavalink node for
|
||||||
// this player.
|
// this player.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue