SharpLink 1.0.0-beta-0005

A lavalink wrapper for Discord.Net

This is a prerelease version of SharpLink.
Install-Package SharpLink -Version 1.0.0-beta-0005
dotnet add package SharpLink --version 1.0.0-beta-0005
<PackageReference Include="SharpLink" Version="1.0.0-beta-0005" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SharpLink --version 1.0.0-beta-0005
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SharpLink

A Lavalink wrapper for Discord.Net!

NuGet Pre Release

Getting Started

  • Follow these instructions to setup Lavalink.
  • Once Lavalink is up and running follow the code example below to setup Sharplink.
DiscordSocketClient client = new DiscordSocketClient();
LavalinkManager lavalinkManager = new LavalinkManager(client, new LavalinkManagerConfig
{
    RESTHost = "localhost",
    RESTPort = 2333,
    WebSocketHost = "localhost",
    WebSocketPort = 80,
    Authorization = "YOUR_SECRET_AUTHORIZATION_KEY",
    TotalShards = 1 
});

Notes:

You don't have to pass a LavalinkManagerConfig since Sharplink uses the default config.

Set TotalShards to the total amount of shards your bot uses. If you don't understand what TotalShards is you are probably not sharding your bot and should set this value to 1.

Use only a single instance of LavaLinkManager. If possible add LavalinkManager to your DI (Dependency Injection).

Once a LavalinkManager is set up it will need to be started. It is recommended you put this in the ready event.

client.Ready += async () =>
{
    await lavalinkManager.StartAsync();
}

From there you can connect to audio channels, play music, and do whatever else you wish to do. Here is an example to connect and play music on a voice channel.

// Get LavalinkPlayer for our Guild and if it's null then join a voice channel.
LavalinkPlayer player = lavalinkManager.GetPlayer(GUILD_ID) ?? await lavalinkManager.JoinAsync(VOICE_CHANNEL);

// Now that we have a player we can go ahead and grab a track and play it
LoadTracksResponse response = await lavalinkManager.GetTracksAsync("IDENTIFIER");
// Gets the first track from the response
LavalinkTrack = response.Tracks.First();
await player.PlayAsync(track);

Notes: To get a track from Youtube use GetTracksAsync($&quot;ytsearch:Query&quot;). To get a track from SoundCloud use GetTracksAsync($&quot;scsearch:Query&quot;).

SharpLink

A Lavalink wrapper for Discord.Net!

NuGet Pre Release

Getting Started

  • Follow these instructions to setup Lavalink.
  • Once Lavalink is up and running follow the code example below to setup Sharplink.
DiscordSocketClient client = new DiscordSocketClient();
LavalinkManager lavalinkManager = new LavalinkManager(client, new LavalinkManagerConfig
{
    RESTHost = "localhost",
    RESTPort = 2333,
    WebSocketHost = "localhost",
    WebSocketPort = 80,
    Authorization = "YOUR_SECRET_AUTHORIZATION_KEY",
    TotalShards = 1 
});

Notes:

You don't have to pass a LavalinkManagerConfig since Sharplink uses the default config.

Set TotalShards to the total amount of shards your bot uses. If you don't understand what TotalShards is you are probably not sharding your bot and should set this value to 1.

Use only a single instance of LavaLinkManager. If possible add LavalinkManager to your DI (Dependency Injection).

Once a LavalinkManager is set up it will need to be started. It is recommended you put this in the ready event.

client.Ready += async () =>
{
    await lavalinkManager.StartAsync();
}

From there you can connect to audio channels, play music, and do whatever else you wish to do. Here is an example to connect and play music on a voice channel.

// Get LavalinkPlayer for our Guild and if it's null then join a voice channel.
LavalinkPlayer player = lavalinkManager.GetPlayer(GUILD_ID) ?? await lavalinkManager.JoinAsync(VOICE_CHANNEL);

// Now that we have a player we can go ahead and grab a track and play it
LoadTracksResponse response = await lavalinkManager.GetTracksAsync("IDENTIFIER");
// Gets the first track from the response
LavalinkTrack = response.Tracks.First();
await player.PlayAsync(track);

Notes: To get a track from Youtube use GetTracksAsync($&quot;ytsearch:Query&quot;). To get a track from SoundCloud use GetTracksAsync($&quot;scsearch:Query&quot;).

Release Notes

- Fixed deadlock in disconnect event (when disconnecting players)
- Removed self deafen completely (no deafen icon)
- Modified LoadTracks API
   1. Removed GetTrackAsync
   2. GetTracksAsync returns a LoadTracksResponse which returns more verbose info if using Lavalink v3

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.0-beta-0005 660 8/15/2018
1.0.0-beta-0004 263 7/9/2018
1.0.0-beta-0002 294 6/23/2018
1.0.0-beta-0001 251 6/3/2018
1.0.0-beta 199 5/31/2018