Skip to content

Commit f55de19

Browse files
authored
Update README.md (#56)
1 parent 56f250c commit f55de19

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,24 @@ To play a track you first need to resolve the song. For this you need to call th
8787
```go
8888
query := "ytsearch:Rick Astley - Never Gonna Give You Up"
8989

90-
err := lavalinkClient.BestNode().LoadTracksHandler(context.TODO(), query, lavalink.NewResultHandler(
91-
func(track lavalink.AudioTrack) {
92-
// Loaded a single track
93-
},
94-
func(playlist lavalink.AudioPlaylist) {
95-
// Loaded a playlist
96-
},
97-
func(tracks []lavalink.AudioTrack) {
98-
// Loaded a search result
99-
},
100-
func() {
101-
// nothing matching the query found
102-
},
103-
func(ex lavalink.FriendlyException) {
104-
// something went wrong while loading the track
105-
},
90+
var toPlay *lavalink.Track
91+
lavalinkClient.BestNode().LoadTracksHandler(context.TODO(), query, disgolink.NewResultHandler(
92+
func(track lavalink.Track) {
93+
// Loaded a single track
94+
toPlay = &track
95+
},
96+
func(playlist lavalink.Playlist) {
97+
// Loaded a playlist
98+
},
99+
func(tracks []lavalink.Track) {
100+
// Loaded a search result
101+
},
102+
func() {
103+
// nothing matching the query found
104+
},
105+
func(err error) {
106+
// something went wrong while loading the track
107+
},
106108
))
107109
```
108110

@@ -122,8 +124,8 @@ after this you can get/create your player and play the track
122124
```go
123125
player := lavalinkClient.Player("guild_id") // This will either return an existing or new player
124126

125-
var track lavalink.Track // track from result handler before
126-
err := player.Play(track)
127+
// toPlay is from result handler in the example above
128+
err := player.Update(context.TODO(), lavalink.WithTrack(*toPlay))
127129
```
128130
now audio should start playing
129131

0 commit comments

Comments
 (0)