Prerequisites
Before connecting to Lavalink, ensure you have:- A running Lavalink server instance
- The server’s connection details (address, password)
- Your Discord bot’s application ID
Creating a DisGoLink Client
Initialize the client
First, create a DisGoLink client with your bot’s application ID:You can also configure the client with optional settings:
Configure the node
Set up your node configuration with the connection details:NodeConfig Fields:
Name: A unique identifier for this nodeAddress: The host and port of your Lavalink serverPassword: Authentication password (configured in Lavalink’s application.yml)Secure: Set totrueto use WSS/HTTPS instead of WS/HTTPSessionID: For resuming existing sessions (leave empty initially)
Add the node
Connect to the Lavalink server by adding the node:The
AddNode() method:- Establishes a WebSocket connection to Lavalink
- Authenticates using the provided password
- Returns a
Nodeinterface for interacting with the server
Connection Status
DisGoLink tracks the connection state through theStatus type:
| Status | Description |
|---|---|
CONNECTING | Initial connection attempt in progress |
CONNECTED | Successfully connected to Lavalink |
RECONNECTING | Attempting to reconnect after disconnection |
DISCONNECTED | Not connected to the server |
Session Resuming
DisGoLink supports session resuming to maintain player state across reconnections.- Enable Resuming
- Resume on Reconnect
Automatic Reconnection
DisGoLink automatically handles reconnection when the connection is lost:- Exponential Backoff: Increases delay between reconnection attempts (up to 30 seconds)
- Infinite Retries: Continues attempting to reconnect indefinitely
- State Preservation: Maintains player state when session resuming is enabled
Managing Multiple Nodes
You can connect to multiple Lavalink servers for load balancing:Cleanup
Always close the client when shutting down:- Close all node connections gracefully
- Stop all active players
- Release associated resources
FAQ
FAQ
Next Steps
Loading Tracks
Learn how to search and load tracks from various sources
Playing Audio
Start playing audio in Discord voice channels