feature: expose player Guild ID, current track
This commit is contained in:
parent
2fd6d25b7b
commit
e1f823649f
1
node.go
1
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)
|
||||
|
|
13
player.go
13
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,
|
||||
|
|
Loading…
Reference in New Issue