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 {
|
switch m.Type {
|
||||||
case eventTrackEnd:
|
case eventTrackEnd:
|
||||||
|
player.track = ""
|
||||||
err = player.handler.OnTrackEnd(player, m.Track, m.Reason)
|
err = player.handler.OnTrackEnd(player, m.Track, m.Reason)
|
||||||
case eventTrackException:
|
case eventTrackException:
|
||||||
err = player.handler.OnTrackException(player, m.Track, m.Reason)
|
err = player.handler.OnTrackException(player, m.Track, m.Reason)
|
||||||
|
|
13
player.go
13
player.go
|
@ -14,11 +14,17 @@ type Player struct {
|
||||||
position int
|
position int
|
||||||
paused bool
|
paused bool
|
||||||
vol int
|
vol int
|
||||||
|
track string
|
||||||
manager *Lavalink
|
manager *Lavalink
|
||||||
node *Node
|
node *Node
|
||||||
handler EventHandler
|
handler EventHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GuildID returns this player's Guild ID
|
||||||
|
func (player *Player) GuildID() string {
|
||||||
|
return player.guildID
|
||||||
|
}
|
||||||
|
|
||||||
// Play will play the given track completely
|
// Play will play the given track completely
|
||||||
func (player *Player) Play(track string) error {
|
func (player *Player) Play(track string) error {
|
||||||
return player.PlayAt(track, 0, 0)
|
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.
|
// Setting a time to 0 will omit it.
|
||||||
func (player *Player) PlayAt(track string, startTime int, endTime int) error {
|
func (player *Player) PlayAt(track string, startTime int, endTime int) error {
|
||||||
player.paused = false
|
player.paused = false
|
||||||
|
player.track = track
|
||||||
|
|
||||||
start := strconv.Itoa(startTime)
|
start := strconv.Itoa(startTime)
|
||||||
end := strconv.Itoa(endTime)
|
end := strconv.Itoa(endTime)
|
||||||
|
@ -48,8 +55,14 @@ func (player *Player) PlayAt(track string, startTime int, endTime int) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Track returns the player's current track
|
||||||
|
func (player *Player) Track() string {
|
||||||
|
return player.track
|
||||||
|
}
|
||||||
|
|
||||||
// Stop will stop the currently playing track
|
// Stop will stop the currently playing track
|
||||||
func (player *Player) Stop() error {
|
func (player *Player) Stop() error {
|
||||||
|
player.track = ""
|
||||||
msg := message{
|
msg := message{
|
||||||
Op: opStop,
|
Op: opStop,
|
||||||
GuildID: player.guildID,
|
GuildID: player.guildID,
|
||||||
|
|
Loading…
Reference in New Issue