{"id":27617496,"url":"https://github.com/lukasl-dev/waterlink","last_synced_at":"2025-04-23T04:04:20.717Z","repository":{"id":41997985,"uuid":"338568221","full_name":"lukasl-dev/waterlink","owner":"lukasl-dev","description":"Waterlink is a Lavalink API client written in Go.","archived":false,"fork":false,"pushed_at":"2023-06-29T13:13:06.000Z","size":473,"stargazers_count":14,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-23T04:04:12.810Z","etag":null,"topics":["discord","discordgo","disgord","go","golang","lavalink","lavaplayer"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/lukasl-dev/waterlink/v2","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukasl-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-13T12:19:31.000Z","updated_at":"2024-12-26T20:23:28.000Z","dependencies_parsed_at":"2024-06-19T00:00:51.050Z","dependency_job_id":"571044f9-f69e-4711-9202-f032c8fedb65","html_url":"https://github.com/lukasl-dev/waterlink","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukasl-dev%2Fwaterlink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukasl-dev%2Fwaterlink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukasl-dev%2Fwaterlink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukasl-dev%2Fwaterlink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukasl-dev","download_url":"https://codeload.github.com/lukasl-dev/waterlink/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250366727,"owners_count":21418771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["discord","discordgo","disgord","go","golang","lavalink","lavaplayer"],"created_at":"2025-04-23T04:04:20.124Z","updated_at":"2025-04-23T04:04:20.671Z","avatar_url":"https://github.com/lukasl-dev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# waterlink\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://golang.org/\"\u003e\n    \u003cimg\n      src=\"https://img.shields.io/badge/Written%20in-Go-%23EF4041?style=for-the-badge\"\n      height=\"30\"\n    /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pkg.go.dev/github.com/lukasl-dev/waterlink/v2\"\u003e\n    \u003cimg\n      src=\"https://img.shields.io/badge/godoc-reference-5272B4.svg?style=for-the-badge\"\n      height=\"30\"\n    /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/lukasl-dev/waterlink/v2\"\u003e\n    \u003cimg\n      src=\"https://goreportcard.com/badge/github.com/lukasl-dev/waterlink/v2?style=for-the-badge\"\n      height=\"30\"\n    /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n## 📖 Table of Contents\n\n- [📖 Table of Contents](#-table-of-contents)\n- [📚 Introduction](#-introduction)\n- [📦 Installation](#-installation)\n- [🍀 Getting started](#-getting-started)\n- [✨ Client related](#-client-related)\n  - [Creating a client](#creating-a-client)\n  - [Loading tracks](#loading-tracks)\n  - [Decoding a single track](#decoding-a-single-track)\n  - [Decoding multiple tracks](#decoding-multiple-tracks)\n- [⛵ Connection related](#-connection-related)\n  - [Opening a connection](#opening-a-connection)\n  - [🦷 Configuring session resuming](#-configuring-session-resuming)\n  - [❌ Disabling session resuming](#-disabling-session-resuming)\n  - [📜 Getting a guild](#-getting-a-guild)\n- [🏠 Guild related](#-guild-related)\n  - [Destroying its player](#destroying-its-player)\n  - [Updating its voice server](#updating-its-voice-server)\n  - [Playing a track](#playing-a-track)\n  - [Stopping the playback](#stopping-the-playback)\n  - [Pausing/Resuming the playback](#pausingresuming-the-playback)\n  - [Seeking the playback](#seeking-the-playback)\n  - [Updating the volume](#updating-the-volume)\n- [📂 Examples](#-examples)\n  - [octave](#octave)\n\n---\n\n## 📚 Introduction\n\nWaterlink is a [Lavalink](https://github.com/freyacodes/Lavalink) API wrapper written in Go.\n\n---\n\n## 📦 Installation\n\n```shell\ngo get -u github.com/lukasl-dev/waterlink/v2\n```\n\n---\n\n## 🍀 Getting started\n\nFor the further guides, a Lavalink instance is used, which uses the following `application.yml` configuration:\n\n```yml\nserver:\n  port: 2333\n  address: 0.0.0.0\nlavalink:\n  server:\n    password: \"youshallnotpass\"\n```\n\n---\n\n## ✨ Client related\n\n### Creating a client\n\n```go\ncreds := waterlink.Credentials{\n  Authorization: \"youshallnotpass\",\n}\n\nclient, err := waterlink.NewClient(\"http://localhost:2333\", creds)\n```\n\n### Loading tracks\n\n```go\nres, err := client.LoadTracks(query.Of(\"https://www.youtube.com/watch?v=dQw4w9WgXcQ\"))\n```\n\n```go\nres, err := client.LoadTracks(query.YouTube(\"Never Gonna Give You Up\"))\n```\n\n```go\nres, err := client.LoadTracks(query.SoundCloud(\"Never Gonna Give You Up\"))\n```\n\n### Decoding a single track\n\n```go\ninfo, err := client.DecodeTrack(\n  \"QAAAoQIAPFJpY2sgQXN0bGV5IC0gTmV2ZXIgR29ubmEgR2l2ZSBZb3UgVXAgKE9mZmljaWFsIE11c2ljIFZpZGVvKQALUmljayBBc3RsZXkAAAAAAANACAALZFF3NHc5V2dYY1EAAQAraHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1kUXc0dzlXZ1hjUQAHeW91dHViZQAAAAAAAAAA\",\n)\n```\n\n### Decoding multiple tracks\n\n```go\ntracks, err := client.DecodeTracks([]string{\n  \"QAAAoQIAPFJpY2sgQXN0bGV5IC0gTmV2ZXIgR29ubmEgR2l2ZSBZb3UgVXAgKE9mZmljaWFsIE11c2ljIFZpZGVvKQALUmljayBBc3RsZXkAAAAAAANACAALZFF3NHc5V2dYY1EAAQAraHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1kUXc0dzlXZ1hjUQAHeW91dHViZQAAAAAAAAAA\",\n})\n```\n\n---\n\n## ⛵ Connection related\n\n### Opening a connection\n\nThe `opts` parameter is optional. In this example, it is used to register an EventHandler. **If this is not needed, omit it.**\n\n```go\ncreds := waterlink.Credentials{\n  Authorization: \"youshallnotpass\", // password of the Lavalink instance\n  UserID:        0,                 // id of the bot user\n}\n\nopts := waterlink.ConnectionOptions{\n  EventHandler: waterlink.EventHandlerFunc(func(evt interface{}) {\n    fmt.Printf(\"%s received\\n\", reflect.TypeOf(evt))\n  }),\n}\n\nconn, err := waterlink.Open(\"ws://localhost:2333\", creds, opts)\n```\n\nTo restore a past session, its resume key can be defined in the credentials.\n\n\u003e See  [Configuring session resuming](#-configuring-session-resuming)\n\n```go\ncreds := waterlink.Credentials{\n  Authorization: \"youshallnotpass\", // password of the Lavalink instance\n  UserID:        0,                 // id of the bot user\n  ResumeKey:     \"myResumeKey\",     // the resume key of the previous session\n}\n```\n\n### 🦷 Configuring session resuming\n\nConfigures a resume key with a timeout of 5 minutes.\n\n```go\nerr := conn.ConfigureResuming(\"myResumeKey\", 5*time.Minute)\n```\n\n### ❌ Disabling session resuming\n\n```go\nerr := conn.DisableResuming()\n```\n\n### 📜 Getting a guild\n\nA guild is necessary to access its audio player. **The function does not check whether the bot user is on this guild.**\n\n```go\ng := conn.Guild(0) // id of the guild to access\n```\n\n---\n\n## 🏠 Guild related\n\nA guild can be obtained via its own ID with the use of a connection.\n\n\u003e See [Getting a guild](#-getting-a-guild)\n\n### Destroying its player\n\n```go\nerr := g.Destroy()\n```\n\n### Updating its voice server\n\nThis function is primarily performed inside a 3rd party libraries' event listener.\n\n\u003e See [Examples](#-examples)\n\n```go\nerr := g.UpdateVoice(\"session\", \"token\", \"endpoint\")\n```\n\n### Playing a track\n\nThe `params` parameter is optional. It can be used to specify more information. **If this is not needed, omit it.**\n\n```go\nparams := waterlink.PlayParams{\n  StartTime: 0,\n  EndTime:   0,\n  Volume:    0,\n  NoReplace: false,\n  Pause:     false,\n}\nerr := g.PlayTrack(t, params) // `t` is the preloaded track to play\n```\n\n### Stopping the playback\n\n```go\nerr := g.Stop()\n```\n\n### Pausing/Resuming the playback\n\n```go\nerr := g.SetPaused(true)\n```\n\n### Seeking the playback\n\n```go\nerr := g.Seek(25 * time.Second) // seek to 25 seconds\n```\n\n### Updating the volume\n\n```go\nerr := g.UpdateVolume(25) // 25%\n```\n\n---\n\n## 📂 Examples\n\n### octave\n\n[Octave](https://github.com/lukasl-dev/octave) is a simple music bot written by myself. It uses [discordgo](https://github.com/bwmarrin/discordgo) as its Discord library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukasl-dev%2Fwaterlink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukasl-dev%2Fwaterlink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukasl-dev%2Fwaterlink/lists"}