Skip to content

Commit

Permalink
Update README.md (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-Mayer authored May 9, 2024
1 parent 56f250c commit f55de19
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,24 @@ To play a track you first need to resolve the song. For this you need to call th
```go
query := "ytsearch:Rick Astley - Never Gonna Give You Up"

err := lavalinkClient.BestNode().LoadTracksHandler(context.TODO(), query, lavalink.NewResultHandler(
func(track lavalink.AudioTrack) {
// Loaded a single track
},
func(playlist lavalink.AudioPlaylist) {
// Loaded a playlist
},
func(tracks []lavalink.AudioTrack) {
// Loaded a search result
},
func() {
// nothing matching the query found
},
func(ex lavalink.FriendlyException) {
// something went wrong while loading the track
},
var toPlay *lavalink.Track
lavalinkClient.BestNode().LoadTracksHandler(context.TODO(), query, disgolink.NewResultHandler(
func(track lavalink.Track) {
// Loaded a single track
toPlay = &track
},
func(playlist lavalink.Playlist) {
// Loaded a playlist
},
func(tracks []lavalink.Track) {
// Loaded a search result
},
func() {
// nothing matching the query found
},
func(err error) {
// something went wrong while loading the track
},
))
```

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

var track lavalink.Track // track from result handler before
err := player.Play(track)
// toPlay is from result handler in the example above
err := player.Update(context.TODO(), lavalink.WithTrack(*toPlay))
```
now audio should start playing

Expand Down

0 comments on commit f55de19

Please sign in to comment.