{"id":19829488,"url":"https://github.com/lavalink-devs/lavalink-client","last_synced_at":"2025-10-07T23:56:53.447Z","repository":{"id":166793065,"uuid":"642292256","full_name":"lavalink-devs/lavalink-client","owner":"lavalink-devs","description":"Lavalink client for lavalink v4","archived":false,"fork":false,"pushed_at":"2025-07-30T19:17:58.000Z","size":562,"stargazers_count":21,"open_issues_count":1,"forks_count":11,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-30T22:04:23.723Z","etag":null,"topics":["discord","hacktoberfest","java","kotlin","lavalink","lavalink-client","music-bot"],"latest_commit_sha":null,"homepage":"https://lavalink.dev/","language":"Kotlin","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/lavalink-devs.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":"2023-05-18T08:39:46.000Z","updated_at":"2025-07-30T19:18:02.000Z","dependencies_parsed_at":"2023-11-08T12:42:02.104Z","dependency_job_id":"aa977ed0-d023-442f-a246-6f56ad21d2d0","html_url":"https://github.com/lavalink-devs/lavalink-client","commit_stats":null,"previous_names":["duncte123/lavalink-client","lavalink-devs/lavalink-client"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/lavalink-devs/lavalink-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavalink-devs%2Flavalink-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavalink-devs%2Flavalink-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavalink-devs%2Flavalink-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavalink-devs%2Flavalink-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lavalink-devs","download_url":"https://codeload.github.com/lavalink-devs/lavalink-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lavalink-devs%2Flavalink-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278866936,"owners_count":26059671,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","hacktoberfest","java","kotlin","lavalink","lavalink-client","music-bot"],"created_at":"2024-11-12T11:18:53.333Z","updated_at":"2025-10-07T23:56:53.428Z","avatar_url":"https://github.com/lavalink-devs.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[VERSION]: https://img.shields.io/maven-central/v/dev.arbjerg/lavalink-client\n\n# Java Lavalink client\n\n\u003e [!WARNING]\n\u003e This is a client for Lavalink v4 only.\n\u003e You cannot use this with Lavalink v3.\n\n\nFeature overview:\n- [Uses reactor](https://projectreactor.io/) (please make sure you understand how reactor works)\n- Works with any discord library (as long as they allow for sending direct request to discord)\n- Load balancing based on server metrics and voice server region.\n- Make your own custom load balancers and penalty providers!\n- Lightweight\n- Compiled for java 17\n\nCurrent version (remove the `v` prefix): [![Latest version][VERSION]](https://search.maven.org/artifact/dev.arbjerg/lavalink-client)\n\nOr copy/download it [here](https://maven.arbjerg.dev/#/releases/dev/arbjerg/lavalink-client)\n\nDocumentation can be found over at [https://client.lavalink.dev/](https://client.lavalink.dev/)\n\nIf you prefer javadoc-style documentation, you can find those [here](https://client.lavalink.dev/javadoc/)\n\n### Gradle instructions\n```gradle\nrepositories {\n    maven(\"https://maven.lavalink.dev/releases\") // Required for the protocol library\n}\n\ndependencies {\n    implementation(\"dev.arbjerg:lavalink-client:VERSION\")\n}\n```\n\n### Maven instructions\n```maven\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ell-releases\u003c/id\u003e\n        \u003cname\u003eLavalink Releases\u003c/name\u003e\n        \u003curl\u003ehttps://maven.lavalink.dev/releases\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n\n\u003cdependency\u003e\n  \u003cgroupId\u003edev.arbjerg\u003c/groupId\u003e\n  \u003cartifactId\u003elavalink-client\u003c/artifactId\u003e\n  \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Installation and usage with JDA\n\nLavalink client ships with a voice interceptor for JDA\n\n```java\n// Helpers is a class provided by this lib!\nString botToken = System.getenv(\"BOT_TOKEN\");\nLavalinkClient client = new LavalinkClient(\n    Helpers.getUserIdFromToken(botToken)\n);\n\nJDABuilder.createDefault(botToken)\n    // .... your jda configuration\n    .setVoiceDispatchInterceptor(new JDAVoiceUpdateListener(client))\n    // .... your jda configuration\n    .build();\n```\n\nthen connect to vc by using the [direct audio controller](https://docs.jda.wiki/net/dv8tion/jda/api/JDA.html#getDirectAudioController()) like this:\n```java\njda.getDirectAudioController().connect(voiceChannel);\n```\n\n\u003e [!IMPORTANT]\n\u003e Using `Guild#getAudioManager()` will ***NOT*** work. This is because the audio manager makes **JDA** connect to the voice channel, and we want to send the event to LavaLink.\n\u003e You can however use `Member#getVoiceState` perfectly fine, this is also how you get the voice channel that your bot is in.\n\u003e\n\u003e You can get the current voice channel of your bot by calling `Guild#getSelfMember()#getVoiceState()#getChannel`\n\n## Installation and usage with Discord4j\n\nInstallation for D4J is a little bit different from usual, mainly because D4j does not have a voice intercepting system.\n\n```java\n// Helpers is a class provided by this lib!\nString botToken = System.getenv(\"BOT_TOKEN\");\nLavalinkClient client = new LavalinkClient(\n    Helpers.getUserIdFromToken(botToken)\n);\n        \nDiscordClient discord = DiscordClientBuilder.create(botToken)\n    .build()\n    .gateway()\n    .setEnabledIntents(IntentSet.all())\n    .login()\n    .block();\n\nD4JVoiceHandler.install(discord, client);\n```\n\nor if you're using kotlin\n\n```kotlin\ndiscord.installVoiceHandler(client)\n```\n\nThen connect like this\n```java\nvar voiceState = /* Get the voice state of the member that ran the command */;\nvar memberVoice = voiceState.getChannel().block();\n\nmemberVoice.sendConnectVoiceState(false, false).subscribe();\n```\n\nAnd disconnect like this\n```java\nvar voiceState = /* Get the voice state of the member that ran the command */;\nvar memberVoice = voiceState.getChannel().block();\n\nmemberVoice.sendDisconnectVoiceState().subscribe();\n```\n\nAlternatively, you can use `Discord4JUtils.leave(gatewayClient, guildId);` as that does not access any voice states.\n\n\n## Examples\nThe following examples are minimal implementations but show how the library works.\n- Java examples\n  - JDA (simple): [link](src/test/java/JavaJDAExample.java)\n  - JDA (Bigger example with queue system): [link](testbot/src/main/java/me/duncte123/testbot/Main.java)\n- Kotlin examples\n  - JDA: [link](src/test/kotlin/testScript.kt)\n  - Discord4J: [link](src/test/kotlin/d4jTestScript.kt)\n\n## Standalone usage\nThis library is made to not rely on and discord libraries and can be used as such.\nIn order to connect to a voice channel without any library you will need a [voice server update event from discord](https://discord.com/developers/docs/topics/voice-connections#retrieving-voice-server-information-example-voice-server-update-payload) containing the token, endpoint and session id.\nIn this example it is assumed that you have this information as an object named `event`.\n\nSample code for connecting to a voice channel without a discord library:\n\n```java\nimport dev.arbjerg.lavalink.client.LavalinkClient;\nimport dev.arbjerg.lavalink.client.Link;\nimport dev.arbjerg.lavalink.client.loadbalancing.VoiceRegion;\nimport dev.arbjerg.lavalink.protocol.v4.VoiceState;\n\n// This is your lavalink client\nLavalinkClient client = new LavalinkClient(/* your bot user id */);\n\n// This is sample code, it will need modifications to work for you\npublic void onDiscordVoiceServerUpdate(VoiceServerUpdateEvent event) {\n    VoiceState lavalinkVoiceState = new VoiceState(\n        event.getToken(),\n        event.getEndpoint(),\n        event.getSessionId()\n    );\n\n    // If you want load-balancing based on the region of the voice server, use the enum.\n    VoiceRegion region = VoiceRegion.fromEndpoint(event.getEndpoint());\n\n    // You can omit the region parameter if you dont need region balancing.\n    Link link = lavalink.getOrCreateLink(event.getGuildId(), region);\n\n    // Finally, tell lavalink to connect.\n    link.onVoiceServerUpdate(lavalinkVoiceState);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flavalink-devs%2Flavalink-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flavalink-devs%2Flavalink-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flavalink-devs%2Flavalink-client/lists"}