Skip to content

Conversation

holasoyender
Copy link

This pull requests adds support for setting a custom Client-Name header when connecting to a Lavalink node.

Example code

// Create a LavalinkClient with the default client name (`Lavalink-Client/<VERSION>`)
..
final LavalinkClient client = new LavalinkClient(Helpers.getUserIdFromToken(token));
..

// Create a LavalinkClient with a custom client name
..
final LavalinkClient client = new LavalinkClient(Helpers.getUserIdFromToken(token), "TestBot");
..

Why?

In the case of multiple bots connecting to the same Lavalink node, it can be useful to identify each bot by a name, and not the library that they are using

Example with the current library

lavalink: 2025-03-05T15:17:25.859Z  INFO 1 --- [Lavalink] [  XNIO-1 task-2] lavalink.server.io.SocketServer          : Connection successfully established from Lavalink-Client/3.2.0
lavalink: 2025-03-05T15:17:26.453Z  INFO 1 --- [Lavalink] [  XNIO-1 task-2] lavalink.server.io.SocketServer          : Connection successfully established from Lavalink-Client/3.2.0
lavalink: 2025-03-05T15:17:27.129Z  INFO 1 --- [Lavalink] [  XNIO-1 task-2] lavalink.server.io.SocketServer          : Connection successfully established from Lavalink-Client/3.2.0

Example with custom client name(s)

lavalink: 2025-03-05T15:17:25.859Z  INFO 1 --- [Lavalink] [  XNIO-1 task-2] lavalink.server.io.SocketServer          : Connection successfully established from TestBot1
lavalink: 2025-03-05T15:17:26.453Z  INFO 1 --- [Lavalink] [  XNIO-1 task-2] lavalink.server.io.SocketServer          : Connection successfully established from TestBot2
lavalink: 2025-03-05T15:17:27.129Z  INFO 1 --- [Lavalink] [  XNIO-1 task-2] lavalink.server.io.SocketServer          : Connection successfully established from TestBot3

@duncte123
Copy link
Collaborator

Unfortunately this is disallowed per the lavalink documentation: https://lavalink.dev/api/websocket.html

@duncte123 duncte123 closed this Mar 5, 2025
@holasoyender
Copy link
Author

Could be possible to implement it using the lavalink documentation? For example

final LavalinkClient client = new LavalinkClient(Helpers.getUserIdFromToken(token), "TestBot");

would connect with the Client-Name header TestBot-LavaLink-Client/<VERSION> or similar, like TestBot-(LavaLink-Client)/<VERSION>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants