{"id":20796506,"url":"https://github.com/disgoorg/disgolink","last_synced_at":"2025-05-06T07:57:12.672Z","repository":{"id":38811845,"uuid":"352591805","full_name":"disgoorg/disgolink","owner":"disgoorg","description":"A Golang Lavalink Client","archived":false,"fork":false,"pushed_at":"2025-04-25T18:28:53.000Z","size":460,"stargazers_count":32,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"v3","last_synced_at":"2025-04-25T19:23:03.273Z","etag":null,"topics":["discord","go","golang","lavalink","lavalink-client"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/disgoorg.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,"zenodo":null}},"created_at":"2021-03-29T09:45:39.000Z","updated_at":"2025-04-25T18:04:40.000Z","dependencies_parsed_at":"2024-05-09T19:47:06.512Z","dependency_job_id":"8adbf2c2-09fd-4958-9777-255c8e428a2e","html_url":"https://github.com/disgoorg/disgolink","commit_stats":{"total_commits":258,"total_committers":13,"mean_commits":"19.846153846153847","dds":0.313953488372093,"last_synced_commit":"f55de19b5aaa0028f0d3fcf77ab542781904224d"},"previous_names":[],"tags_count":86,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disgoorg%2Fdisgolink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disgoorg%2Fdisgolink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disgoorg%2Fdisgolink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disgoorg%2Fdisgolink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/disgoorg","download_url":"https://codeload.github.com/disgoorg/disgolink/tar.gz/refs/heads/v3","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252645172,"owners_count":21781895,"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","go","golang","lavalink","lavalink-client"],"created_at":"2024-11-17T16:27:29.769Z","updated_at":"2025-05-06T07:57:12.633Z","avatar_url":"https://github.com/disgoorg.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/disgoorg/disgolink.svg)](https://pkg.go.dev/github.com/disgoorg/disgolink)\n[![Go Report](https://goreportcard.com/badge/github.com/disgoorg/disgolink/v3)](https://goreportcard.com/report/github.com/disgoorg/disgolink)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/disgoorg/disgolink?filename=go.mod)](https://golang.org/doc/devel/release.html)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/disgoorg/disgolink/blob/master/LICENSE)\n[![Disgolink Version](https://img.shields.io/github/v/release/disgoorg/disgolink?label=release)](https://github.com/disgoorg/disgolink/releases/latest)\n[![Support Discord](https://discord.com/api/guilds/817327181659111454/widget.png)](https://discord.gg/NFmvZYmZMF)\n\n\u003cimg align=\"right\" src=\"/.github/disgolink.png\" width=192 alt=\"discord gopher\"\u003e\n\n# DisGoLink\n\nDisGoLink is a [Lavalink](https://github.com/freyacodes/Lavalink) Client written in [Golang](https://golang.org/) which supports the latest Lavalink 4.0.0+ release and the new plugin system. \n\nWhile DisGoLink can be used with any [Discord](https://discord.com) Library [DisGo](https://github.com/disgoorg/disgo) is the best fit for it as usage with other Libraries can be a bit annoying due to different [Snowflake](https://github.com/disgoorg/snowflake) implementations.\n\n* [DiscordGo](https://github.com/bwmarrin/discordgo) `string`\n* [Arikawa](https://github.com/diamondburned/arikawa) `type Snowflake uint64`\n* [Disgord](https://github.com/andersfylling/disgord) `type Snowflake uint64`\n* [DisGo](https://github.com/disgoorg/disgo) `type ID uint64`\n\nThis Library uses the [Disgo Snowflake](https://github.com/disgoorg/snowflake) package like DisGo\n\n## Getting Started\n\n### Installing\n\n```sh\ngo get github.com/disgoorg/disgolink/v3\n```\n\n## Usage\n\n### Setup\n\nFirst create a new lavalink instance. You can do this either with\n\n```go\nimport (\n\t\"github.com/disgoorg/snowflake/v2\"\n\t\"github.com/disgoorg/disgolink/v3/disgolink\"\n)\n\nvar userID = snowflake.ID(1234567890)\nlavalinkClient := disgolink.New(userID)\n```\n\nYou also need to forward the `VOICE_STATE_UPDATE` and `VOICE_SERVER_UPDATE` events to DisGoLink.\nJust register an event listener for those events with your library and call `lavalinkClient.OnVoiceStateUpdate` (make sure to only forward your bots voice update event!) and `lavalinkClient.OnVoiceServerUpdate`\n\n\nFor DisGo this would look like this\n```go\nclient, err := disgo.New(Token,\n    bot.WithEventListenerFunc(b.onVoiceStateUpdate),\n    bot.WithEventListenerFunc(b.onVoiceServerUpdate),\n)\n\nfunc onVoiceStateUpdate(event *events.GuildVoiceStateUpdate) {\n    // filter all non bot voice state updates out\n    if event.VoiceState.UserID != client.ApplicationID() {\n        return\n    }\n    lavalinkClient.OnVoiceStateUpdate(context.TODO(), event.VoiceState.GuildID, event.VoiceState.ChannelID, event.VoiceState.SessionID)\n}\n\nfunc onVoiceServerUpdate(event *events.VoiceServerUpdate) {\n    lavalinkClient.OnVoiceServerUpdate(context.TODO(), event.GuildID, event.Token, *event.Endpoint)\n}\n```\n\nThen you add your lavalink nodes. This directly connects to the nodes and is a blocking call\n```go\nnode, err := lavalinkClient.AddNode(context.TODO(), lavalink.NodeConfig{\n\t\tName:      \"test\", // a unique node name\n\t\tAddress:   \"localhost:2333\",\n\t\tPassword:  \"youshallnotpass\",\n\t\tSecure:    false, // ws or wss\n\t\tSessionID: \"\", // only needed if you want to resume a previous lavalink session\n})\n```\n\nafter this you can play songs from lavalinks supported sources.\n\n### Loading a track\n\nTo play a track you first need to resolve the song. For this you need to call the Lavalink rest `loadtracks` endpoint which returns a result with various track instances. Those tracks can then be played.\n```go\nquery := \"ytsearch:Rick Astley - Never Gonna Give You Up\"\n\nvar toPlay *lavalink.Track\nlavalinkClient.BestNode().LoadTracksHandler(context.TODO(), query, disgolink.NewResultHandler(\n\tfunc(track lavalink.Track) {\n\t\t// Loaded a single track\n\t\ttoPlay = \u0026track\n\t},\n\tfunc(playlist lavalink.Playlist) {\n\t\t// Loaded a playlist\n\t},\n\tfunc(tracks []lavalink.Track) {\n\t\t// Loaded a search result\n\t},\n\tfunc() {\n\t\t// nothing matching the query found\n\t},\n\tfunc(err error) {\n\t\t// something went wrong while loading the track\n\t},\n))\n```\n\n### Playing a track\n\nTo play a track we first need to connect to the voice channel.\nConnecting to a voice channel differs with every lib but here are some quick usages with some\n```go\n// DisGo\nerr := client.UpdateVoiceState(context.TODO(), guildID, channelID, false, false)\n\n// DiscordGo\nerr := session.ChannelVoiceJoinManual(guildID, channelID, false, false)\n```\n\nafter this you can get/create your player and play the track\n```go\nplayer := lavalinkClient.Player(\"guild_id\") // This will either return an existing or new player\n\n// toPlay is from result handler in the example above\nerr := player.Update(context.TODO(), lavalink.WithTrack(*toPlay))\n```\nnow audio should start playing\n\n### Listening for events\n\nYou can listen for following lavalink events\n* `PlayerUpdateMessage` Emitted every x seconds (default 5) with the current player state\n* `PlayerPause` Emitted when the player is paused\n* `PlayerResume` Emitted when the player is resumed\n* `TrackStart` Emitted when a track starts playing\n* `TrackEnd` Emitted when a track ends\n* `TrackException` Emitted when a track throws an exception\n* `TrackStuck` Emitted when a track gets stuck\n* `WebsocketClosed` Emitted when the voice gateway connection to lavalink is closed\n\nfor this add and event listener for each event to your `Client` instance when you create it or with `Client.AddEventListener`\n```go\nlavalinkClient := disgolink.New(userID,\n    disgolink.WithListenerFunc(onPlayerUpdate),\n    disgolink.WithListenerFunc(onPlayerPause),\n\tdisgolink.WithListenerFunc(onPlayerResume),\n\tdisgolink.WithListenerFunc(onTrackStart),\n\tdisgolink.WithListenerFunc(onTrackEnd),\n\tdisgolink.WithListenerFunc(onTrackException),\n\tdisgolink.WithListenerFunc(onTrackStuck),\n\tdisgolink.WithListenerFunc(onWebSocketClosed),\n)\n\nfunc onPlayerUpdate(player disgolink.Player, event lavalink.PlayerUpdateMessage) {\n    // do something with the event\n}\n\nfunc onPlayerPause(player disgolink.Player, event lavalink.PlayerPauseEvent) {\n    // do something with the event\n}\n\nfunc onPlayerResume(player disgolink.Player, event lavalink.PlayerResumeEvent) {\n    // do something with the event\n}\n\nfunc onTrackStart(player disgolink.Player, event lavalink.TrackStartEvent) {\n    // do something with the event\n}\n\nfunc onTrackEnd(player disgolink.Player, event lavalink.TrackEndEvent) {\n    // do something with the event\n}\n\nfunc onTrackException(player disgolink.Player, event lavalink.TrackExceptionEvent) {\n    // do something with the event\n}\n\nfunc onTrackStuck(player disgolink.Player, event lavalink.TrackStuckEvent) {\n    // do something with the event\n}\n\nfunc onWebSocketClosed(player disgolink.Player, event lavalink.WebSocketClosedEvent) {\n    // do something with the event\n}\n```\n\n### Plugins\n\nLavalink added [plugins](https://lavalink.dev/plugins.html) in `v3.5` . DisGoLink exposes a similar API for you to use. With that you can create plugins which require server \u0026 client work.\nTo see what you can do with plugins see [here](disgolink/plugin.go)\n\nYou register plugins when creating the client instance like this\n```go\nlavalinkClient := disgolink.New(userID, disgolink.WithPlugins(yourPlugin))\n```\n\nHere is a list of plugins(you can pr your own to here):\n* [SponsorBlock](https://github.com/disgoorg/sponsorblock-plugin) support for [Lavalink Sponsorblock-Plugin](https://github.com/topi314/SponsorBlock-Plugin)\n* [LavaQueue](https://github.com/disgoorg/lavaqueue-plugin) support for [Lavalink LavaQueue-Plugin](https://github.com/topi314/LavaQueue)\n* [LavaSrc](https://github.com/disgoorg/sponsorblock-plugin) support for [Lavalink LavaSrc-Plugin](https://github.com/topi314/LavaSrc)\n* [LavaLyrics](https://github.com/disgoorg/lavalyrics-plugin) support for [Lavalink LavaLyrics-Plugin](https://github.com/topi314/LavaLyrics)\n* [LavaSearch](https://github.com/disgoorg/lavasearch-plugin) support for [Lavalink LavaSearch-Plugin](https://github.com/topi314/LavaSearch)\n\n## Examples\n\nYou can find examples under \n* disgo: [_example](https://github.com/disgoorg/disgolink/tree/v2/_examples/disgo)\n* discordgo:   [_examples](https://github.com/disgoorg/disgolink/tree/v2/_examples/discordgo)\n\n## Troubleshooting\n\nFor help feel free to open an issue or reach out on [Discord](https://discord.gg/NFmvZYmZMF)\n\n## Contributing\n\nContributions are welcomed but for bigger changes please first reach out via [Discord](https://discord.gg/NFmvZYmZMF) or create an issue to discuss your intentions and ideas.\n\n## License\n\nDistributed under the [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/disgoorg/disgolink/blob/master/LICENSE). See LICENSE for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisgoorg%2Fdisgolink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdisgoorg%2Fdisgolink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisgoorg%2Fdisgolink/lists"}