From e1f823649f9a1e6da8deab3fa0f4faa025b8fd80 Mon Sep 17 00:00:00 2001 From: Christopher F Date: Sat, 25 Aug 2018 22:58:41 -0400 Subject: [PATCH] feature: expose player Guild ID, current track --- node.go | 1 + player.go | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/node.go b/node.go index d134154..9a81197 100644 --- a/node.go +++ b/node.go @@ -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) diff --git a/player.go b/player.go index e3da9c7..89cbf1a 100644 --- a/player.go +++ b/player.go @@ -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,