{"id":21134342,"url":"https://github.com/freyacodes/lavalink-client","last_synced_at":"2025-10-16T03:08:32.058Z","repository":{"id":37096120,"uuid":"141700739","full_name":"freyacodes/Lavalink-Client","owner":"freyacodes","description":"The classic Lavalink client for bots written for JVM using JDA or other frameworks","archived":false,"fork":false,"pushed_at":"2023-08-09T23:12:33.000Z","size":330,"stargazers_count":40,"open_issues_count":4,"forks_count":52,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-04T15:53:52.322Z","etag":null,"topics":["hacktoberfest","jda","lavalink"],"latest_commit_sha":null,"homepage":"","language":"Java","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/freyacodes.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":"2018-07-20T10:51:13.000Z","updated_at":"2025-02-27T17:10:38.000Z","dependencies_parsed_at":"2024-11-20T06:27:18.705Z","dependency_job_id":"589015d2-ccf6-4b76-93bc-e963630d88dd","html_url":"https://github.com/freyacodes/Lavalink-Client","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/freyacodes/Lavalink-Client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freyacodes%2FLavalink-Client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freyacodes%2FLavalink-Client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freyacodes%2FLavalink-Client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freyacodes%2FLavalink-Client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/freyacodes","download_url":"https://codeload.github.com/freyacodes/Lavalink-Client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/freyacodes%2FLavalink-Client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264380350,"owners_count":23599033,"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":["hacktoberfest","jda","lavalink"],"created_at":"2024-11-20T06:27:02.331Z","updated_at":"2025-10-16T03:08:27.000Z","avatar_url":"https://github.com/freyacodes.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lavalink Client [![Release](https://img.shields.io/github/tag/freyacodes/Lavalink-Client.svg)](https://jitpack.io/#freyacodes/Lavalink-Client)\n\n## Installation\nLavalink does not have a maven repository and instead uses Jitpack.\nYou can add the following to your POM if you're using Maven:\n```xml\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.github.freyacodes\u003c/groupId\u003e\n        \u003cartifactId\u003eLavalink-Client\u003c/artifactId\u003e\n        \u003cversion\u003ex.y.z\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\nOr Gradle:\n\n```groovy\n    repositories {\n        maven { url 'https://jitpack.io' }\n    }\n\n    dependencies {\n        compile group: 'com.github.freyacodes', name: 'Lavalink-Client', version: 'x.y.z'\n    }\n```\n\n### Jitpack versions\nJitpack versioning is based on git branches and commit hashes, or tags. Eg:\n\n```\nab123c4d\nmaster-SNAPSHOT\ndev-SNAPSHOT\n3.2\n```\n\n***Note:*** The above versions are for example purposes only.\n\nVersion tags of this client are expected to roughly follow lavalink server versioning.\n\n## Migrating from v3 to v4\nVersion 4 drops JDA3 support in favour of JDA4. This uses a non-internal JDA API to intercept voice handling. This requires adding an interceptor to your `JDABuilder` or `DefaultShardManagerBuilder`. See examples of using `#setVoiceDispatchInterceptor` below.\n\n## Migrating from v2 to v3\nThe v3 client has been made to be generic, meaning that the base client can now be used without JDA.\nThis will break bots built on v2, as the classes `Lavalink` and `Link` has been made abstract.\nFor use with JDA you will want to reference the JDA-specific implementations `JdaLavalink` and `JdaLink`.\n\nIf you for some reason need to use the abstract classes, you might experience type erasure problems.\n\n## Usage\nThis guide assumes you have JDA in your classpath, and your bot is written with JDA.\n\n### Configuring Lavalink\nAll your shards should share a single Lavalink instance. Here is how to construct an instance:\n\n```java\nJdaLavalink lavalink = new JdaLavalink(\n                myDiscordUserId,\n                fixedNumberOfShards,\n                shardId -\u003e getJdaInstanceFromId(shardId)\n        );\n```\n\nThe interesting part is the third parameter, which is a `Function\u003cInteger, JDA\u003e`.\nYou must define this `Function` so that Lavalink can get your current JDA instance for that shardId.\n\nYou can now register remote nodes to your Lavalink instance:\n```java\nlavalink.addNode(\"ws://example.com\", \"my-secret-password\");\n```\n\nIf a node is down Lavalink will continue trying to connect until you remove the node.\nWhen a node dies Lavalink will attempt to balance the load unto other nodes if they are available.\n\nNext when you are building a shard, you must register Lavalink as an event listener to bind your shard.\nYou may not register more than one Lavalink instance per shard.\n\n```java\nnew JDABuilder(AccountType.BOT)\n        .addEventListener(myJdaLavalinkInstance)\n        .setVoiceDispatchInterceptor(myJdaLavalinkInstance.getVoiceInterceptor())\n        ...\n```\n\n### The Link class\nThe `JdaLink` class is the state of one of your guilds in relation to Lavalink.\nA `JdaLink` object is instantiated if it doesn't exist already when invoking `JdaLavalink#getLink(Guild/String)`.\n\n```java\nJdaLink someLink = myLavalink.getLink(someGuild);\nsomeLink = myLavalink.getLink(someGuildId);\n```\n\nHere are a few important methods:\n* `connect(VoiceChannel channel)` connects you to a VoiceChannel.\n  * Note: This also works for moving to a new channel, in which case we will disconnect first.\n* `disconnect()` disconnects from the VoiceChannel.\n* `destroy()` resets the state of the `Link` and removes Lavalink's internal reference to this Link. This `Link` should be discarded.\n* `getPlayer()` returns an `IPlayer` you can use to play music with.\n\nThe `IPlayer` more or less works like a drop-in replacement for Lavaplayer's `AudioPlayer`. Which leads me to...\n\n**Warning:** You should not use JDA's `AudioManager#openAudioConnection()` or `AudioManager#closeAudioConnection()` when Lavalink is being used. Use `Link` instead.\n\n### Using Lavalink and Lavaplayer in the same codebase\nOne of the requirements for Lavalink to work with FredBoat was to make Lavalink optional, so we could support selfhosters who do not want to run Lavalink. (This has since been removed from FredBoat).\n\nLavalink-Client adds an abstraction layer:\n* `IPlayer` in place of `AudioPlayer`\n* `IPlayerEventListener` in place of `AudioEventListener`\n* `PlayerEventListenerAdapter` in place of `AudioEventAdapter`\n\nWhat this means is that if you want to use Lavaplayer directly instead, you can still use `IPlayer`.\n```java\nIPlayer myNewPlayer = isLavalinkEnabled\n        ? lavalink.getLink(guildId).getPlayer()\n        : new LavaplayerPlayerWrapper(myLavaplayerPlayerManager.createPlayer());\n```\n\n### Node statistics\nLavalink-Client allows access to the client WebSockets with `Lavalink#getNodes()`.\nThis is useful if you want to read the statistics and state of a node connection.\n\nUseful methods:\n* `isAvailable()` Whether or not we are connected and can play music.\n* `getRemoteUri()` Returns a `URI` of the remote address.\n* `getStats()` Returns a nullable `RemoteStats` object, with statistics from the Lavalink Server. Updated every minute.\n\n# Common pitfalls\nIf you are experiencing problems with playing audio or joining a voice channel with Lavalink please check to see if all these apply to you:\n\n1. You are adding the Lavalink instance to your JDABuilder *before* building it. Lavalink must be able to receive the ready event.\n2. You don't have multiple Lavalink instances.\n3. You don't attempt to join a voice channel via JDA directly.\n\n# Using this client without JDA\nSince this client has been rewritten to be generic, it is possible to write custom implementations of the abstract \n`Lavalink` and `Link` classes. \n\nThe client was made generic with FredBoat in mind, but if you need generics for your own purposes, you can open an issue \nand I can elaborate on this brief documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreyacodes%2Flavalink-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreyacodes%2Flavalink-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreyacodes%2Flavalink-client/lists"}