feature: add volume cache to player

This commit is contained in:
Christopher F 2018-08-25 22:24:56 -04:00
parent cfb1661b64
commit 2fd6d25b7b
2 changed files with 9 additions and 0 deletions

View File

@ -158,6 +158,7 @@ func (node *Node) CreatePlayer(guildID string, sessionID string, event VoiceServ
manager: node.manager,
node: node,
handler: handler,
vol: 100,
}
node.manager.players[guildID] = player
return player, nil

View File

@ -13,6 +13,7 @@ type Player struct {
time int
position int
paused bool
vol int
manager *Lavalink
node *Node
handler EventHandler
@ -111,6 +112,8 @@ func (player *Player) Volume(volume int) error {
return errVolumeOutOfRange
}
player.vol = volume
msg := message{
Op: opVolume,
GuildID: player.guildID,
@ -124,6 +127,11 @@ func (player *Player) Volume(volume int) error {
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
// this player.
//