High performance Lavalink wrapper for .NET
Important
We now have a FAQ channel for quick questions on the Lavalink4NET Support Server
Lavalink4NET is a Lavalink wrapper with node clustering, caching and custom players for .NET with support for Discord.Net, DSharpPlus, Remora, and NetCord.
-
⚖️ Node Clustering / Load Balancing
Distribute load across nodes for efficient and reliable audio playback (for large scale bots). -
✳️ Extensible
Customize and enhance features using plugins to match your bot's needs. -
🎤 Lyrics
Display song lyrics alongside audio playback to enrich the user experience. -
🗳️ Queueing / Voting-System
Let users queue tracks and vote on the next songs, enhancing collaborative playlists. -
🎵 Track Decoding and Encoding
Lavalink4NET supports high efficient track decoding and encoding of lavaplayer track identifiers. -
🔄 Auto-Reconnect and Resuming
Maintain uninterrupted audio playback during connection disruptions. -
🔌 Fully Asynchronous Interface
Effortlessly communicate with the Lavalink audio server without causing delays in your bot. All actions that can be offloaded are asynchronous and can be canceled at any time if needed. -
📝 Logging (optional)
Enable insights for troubleshooting and debugging. -
⚡ Request Caching (optional)
Improve performance by reducing redundant requests. -
⏱️ Inactivity Tracking (optional)
Monitor inactive players and disconnect them to save resources. -
🖋️ Supports Lavalink plugins
Expand capabilities by integrating with Lavalink plugins. -
🎶 Custom players
Manage audio playback instances tailored to your bot's requirements. -
🖼️ Artwork resolution
Lavalink4NET allows the user to resolve artwork images for the tracks to display an appealing image to the user. -
🎚️ Audio filter support
Lavalink4NET supports all audio filters provided by lavaplayer and even more when installing the ExtraFilters plugin. -
📊 Statistics tracking support
Lavalink4NET supports tracking and evaluation of node statistics. In clustering, node statistics can be used to evaluate the best node for efficient resource usage. -
➕ Compatible with DSharpPlus, Discord.Net, Remora, and NetCord.
Lavalink4NET has an adaptive client API, meaning it can support any discord client. Currently, DSharpPlus, Discord.Net, Remora and NetCord are supported out-of-the-box.
Important
You can find the documentation for Lavalink4NET v4 here.
Lavalink4NET offers high flexibility and extensibility by providing an isolated interface. You can extend Lavalink4NET by adding additional packages which add integrations with other services, support for additional lavalink/lavaplayer plugins, or additional client support.
-
Lavalink4NET.Discord.Net
Enhance your Discord bots with advanced audio playback using this integration for Lavalink4NET. Designed for end users building Discord.Net-based applications. -
Lavalink4NET.DSharpPlus
Add powerful audio playback to your DSharpPlus-based applications with this integration for Lavalink4NET. Suitable for end users developing with DSharpPlus. -
Lavalink4NET.Remora.Discord
Add powerful audio playback to your Remora-based discord bots with this integration for Lavalink4NET. Suitable for end users developing with Remora. -
Lavalink4NET.NetCord
Add powerful audio playback to your NetCord-based discord bots with this integration for Lavalink4NET. Suitable for end users developing with NetCord.
- Lavalink4NET.Cluster
Scale and improve performance by using multiple Lavalink nodes with this cluster support module. Ideal for handling high-demand music streaming applications.
-
Lavalink4NET.Integrations.ExtraFilters
Enhance your audio playback experience with extra filters in Lavalink4NET. Apply additional audio effects and modifications to customize the sound output. Requires the installation of the corresponding plugin on the Lavalink node. -
Lavalink4NET.Integrations.SponsorBlock
Integrate SponsorBlock functionality into Lavalink4NET. Automatically skip sponsored segments in videos for a seamless and uninterrupted playback experience. Requires the installation of the corresponding plugin on the Lavalink node. -
Lavalink4NET.Integrations.TextToSpeech
Enable text-to-speech functionality in Lavalink4NET. Convert written text into spoken words, allowing your application to generate and play audio from text inputs. Requires the installation of the corresponding plugin on the Lavalink node. -
Lavalink4NET.Integrations.LyricsJava
Fetch timed lyrics from youtube or non-timed lyrics from genius. Automatically fetches lyrics for the current track. Requires the installation of the corresponding plugin on the Lavalink node.
-
Lavalink4NET.Lyrics
Fetch and display song lyrics from lyrics.ovh with this lyrics service integrated with Lavalink4NET. Enhance the music experience for your users. -
Lavalink4NET.Artwork
Artwork resolution service for the Lavalink4NET client library. -
Lavalink4NET.InactivityTracking
Optimize resource usage by tracking and disconnecting inactive players. Ensure efficient audio playback in your application.
-
Lavalink4NET
This core library is used to implement client wrappers. It is not intended for end users. Please use Lavalink4NET.Discord.Net, Lavalink4NET.DSharpPlus, Lavalink4NET.Remora.Discord or Lavalink4NET.NetCord instead. -
Lavalink4NET.Abstractions
General abstractions and common primitives for the Lavalink4NET client library. -
Lavalink4NET.Protocol
Protocol implementation for the Lavalink4NET client library used to interact with the Lavalink REST API. -
Lavalink4NET.Rest
Easily interact with the Lavalink REST API using this REST API client primitives library. Build custom functionalities or integrate Lavalink4NET with other services.
- At least one lavalink node
- At least .NET 6
Lavalink4NET works by using dependency injection to make management of services very easy. You just have to add services.AddLavalink();
to your startup code. We prefer using the host application builder to manage services required by Lavalink4NET.
var builder = new HostApplicationBuilder(args);
builder.Services.AddLavalink(); // Contained in the client support packages
var app = builder.Build();
var audioService = app.Services.GetRequiredService<IAudioService>();
// [...]
(ℹ️) Since Lavalink4NET v4, boilerplate code has been drastically reduced. It is also no longer required to initialize the node.
(ℹ️) If you only use Dependency Injection without
Microsoft.Extensions.Hosting
, you may need to call.StartAsync()
on various Lavalink4NET services, likeIAudioService
,IInactivityTrackingService
, ...
// Play a track
var playerOptions = new LavalinkPlayerOptions
{
InitialTrack = new TrackQueueItem("https://www.youtube.com/watch?v=dQw4w9WgXcQ"),
};
await audioService.Players
.JoinAsync(<guild id>, <voice channel id>, playerOptions, stoppingToken)
.ConfigureAwait(false);
You can take a look at the example bots.