feature: expose player Guild ID, current track

This commit is contained in:
Christopher F 2018-08-25 22:58:41 -04:00
parent 2fd6d25b7b
commit e1f823649f
2 changed files with 14 additions and 0 deletions

View File

@ -120,6 +120,7 @@ func (node *Node) onEvent(msgType int, msg []byte) error {
switch m.Type {
case eventTrackEnd:
player.track = ""
err = player.handler.OnTrackEnd(player, m.Track, m.Reason)
case eventTrackException:
err = player.handler.OnTrackException(player, m.Track, m.Reason)

View File

@ -14,11 +14,17 @@ type Player struct {
position int
paused bool
vol int
track string
manager *Lavalink
node *Node
handler EventHandler
}
// GuildID returns this player's Guild ID
func (player *Player) GuildID() string {
return player.guildID
}
// Play will play the given track completely
func (player *Player) Play(track string) error {
return player.PlayAt(track, 0, 0)
@ -29,6 +35,7 @@ func (player *Player) Play(track string) error {
// Setting a time to 0 will omit it.
func (player *Player) PlayAt(track string, startTime int, endTime int) error {
player.paused = false
player.track = track
start := strconv.Itoa(startTime)
end := strconv.Itoa(endTime)
@ -48,8 +55,14 @@ func (player *Player) PlayAt(track string, startTime int, endTime int) error {
return err
}
// Track returns the player's current track
func (player *Player) Track() string {
return player.track
}
// Stop will stop the currently playing track
func (player *Player) Stop() error {
player.track = ""
msg := message{
Op: opStop,
GuildID: player.guildID,