Discord.Net.Labs.Core
3.0.2
See the version list below for details.
dotnet add package Discord.Net.Labs.Core --version 3.0.2
NuGet\Install-Package Discord.Net.Labs.Core -Version 3.0.2
<PackageReference Include="Discord.Net.Labs.Core" Version="3.0.2" />
paket add Discord.Net.Labs.Core --version 3.0.2
#r "nuget: Discord.Net.Labs.Core, 3.0.2"
// Install Discord.Net.Labs.Core as a Cake Addin #addin nuget:?package=Discord.Net.Labs.Core&version=3.0.2 // Install Discord.Net.Labs.Core as a Cake Tool #tool nuget:?package=Discord.Net.Labs.Core&version=3.0.2
Discord.Net Labs
Join our Discord server for support using labs
This repo is a custom fork of Discord.Net that introduces the newest features of discord for testing and experimenting. Nothing here is guaranteed to work but you are more than welcome to submit bugs in the issues tabs
Known issues
Labs will not work with normal package of Playwo's InteractivityAddon. The reason is that his package depends on the base discord.net lib. You can instead use the InteractivityAddon.Labs package which implements some of the features added in Discord.Net-Labs.
How to use
Setting up labs in your project is really simple, here's how to do it:
- Remove Discord.Net from your project
- Add Discord.Net Labs nuget to your project
- Enjoy!
Listening for interactions
// Subscribe to the InteractionCreated event
client.InteractionCreated += Client_InteractionCreated;
...
private async Task Client_InteractionCreated(SocketInteraction interaction)
{
// Checking the type of this interaction
switch (interaction)
{
// Slash commands
case SocketSlashCommand commandInteraction:
await MySlashCommandHandler(commandInteraction);
break;
// Button clicks/selection dropdowns
case SocketMessageComponent componentInteraction:
await MyMessageComponentHandler(componentInteraction);
break;
// Unused or Unknown/Unsupported
default:
break;
}
}
Simple handling slash commands
private async Task MySlashCommandHandler(SocketSlashCommand interaction)
{
// Checking command name
if (interaction.Data.Name == "ping")
{
// Respond to interaction with message.
// You can also use "ephemeral" so that only the original user of the interaction sees the message
await interaction.RespondAsync($"Pong!", ephemeral: true);
// Also you can followup with a additional messages, which also can be "ephemeral"
await interaction.FollowupAsync($"PongPong!", ephemeral: true);
}
}
Simple handling button clicks and selection dropdowns
private async Task MyMessageComponentHandler(SocketMessageComponent interaction)
{
// Get the custom ID
var customId = interaction.Data.CustomId;
// Get the user
var user = (SocketGuildUser) interaction.User;
// Get the guild
var guild = user.Guild;
// Respond with the update message. This edits the message which this component resides.
await interaction.UpdateAsync(msgProps => msgProps.Content = $"Clicked {interaction.Data.CustomId}!");
// Also you can followup with a additional messages
await interaction.FollowupAsync($"Clicked {interaction.Data.CustomId}!", ephemeral: true);
// If you are using selection dropdowns, you can get the selected label and values using these
var selectedLabel = ((SelectMenu) interaction.Message.Components.First().Components.First()).Options.FirstOrDefault(x => x.Value == interaction.Data.Values.FirstOrDefault())?.Label;
var selectedValue = interaction.Data.Values.First();
}
Note: The example above assumes that the selection dropdown is expecting only 1 returned value, if you configured your dropdown for multiple values, you'll need to modify the code slightly.
Sending messages with buttons
Theres a new field in all SendMessageAsync
functions that takes in a MessageComponent
, you can use it like so:
var builder = new ComponentBuilder().WithButton("Hello!", customId: "id_1", ButtonStyle.Primary, row: 0);
await Context.Channel.SendMessageAsync("Test buttons!", component: builder.Build());
Sending messages with selection dropdowns
Theres a new field in all SendMessageAsync
functions that takes in a MessageComponent
, you can use it like so:
var builder = new ComponentBuilder()
.WithSelectMenu(new SelectMenuBuilder()
.WithCustomId("id_2")
.WithPlaceholder("This is a placeholder")
.AddOption(
label: "Option",
value: "value1",
description: "Evan pog champ",
emote: Emote.Parse("<:evanpog:810017136814194698>")
)
.AddOption("Option B", "value2", "Option B is poggers")
);
await Context.Channel.SendMessageAsync("Test selection!", component: builder.Build());
Note: You can only have 5 buttons per row and 5 rows per message. If a row contains a selection dropdown it cannot contain any buttons.
Slash Commands & Context Menu Commands
Slash command & Context command examples and how to's can be found here.
Message Components
Message components (buttons, menus, etc) examples and how to's can be found here
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.1
- Newtonsoft.Json (>= 12.0.2)
- System.Collections.Immutable (>= 1.3.1)
- System.Interactive.Async (>= 4.0.0)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 12.0.2)
- System.Collections.Immutable (>= 1.3.1)
- System.Interactive.Async (>= 4.0.0)
-
.NETStandard 2.1
- Newtonsoft.Json (>= 12.0.2)
- System.Collections.Immutable (>= 1.3.1)
- System.Interactive.Async (>= 4.0.0)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on Discord.Net.Labs.Core:
Package | Downloads |
---|---|
Discord.Net.Labs.Rest
A core Discord.Net Labs library containing the REST client and models. |
|
Discord.Net.Labs.WebSocket
A core Discord.Net Labs library containing the WebSocket client and models. |
|
Discord.Net.Labs.Commands
A Discord.Net Labs extension adding support for bot commands. |
|
Discord.Net.Labs
An experimental fork of Discord.NET that adds all the new discord features to play around with! This metapackage includes all of the optional Discord.Net Labs components. |
|
Discord.Net.Labs.Webhook
A core Discord.Net Labs library containing the Webhook client and models. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
3.6.1 | 27,434 | 12/24/2021 | |
3.6.0 | 2,247 | 12/24/2021 | |
3.5.0 | 3,819 | 12/15/2021 | |
3.4.9 | 6,795 | 12/6/2021 | |
3.4.8 | 6,875 | 12/4/2021 | |
3.4.7 | 4,895 | 11/28/2021 | |
3.4.6 | 1,730 | 11/27/2021 | |
3.4.5 | 1,569 | 11/27/2021 | |
3.4.4 | 1,655 | 11/27/2021 | |
3.4.3 | 1,649 | 11/27/2021 | |
3.4.2 | 4,347 | 11/26/2021 | |
3.4.1 | 3,548 | 11/26/2021 | |
3.4.0 | 3,669 | 11/26/2021 | |
3.3.3 | 2,553 | 11/23/2021 | |
3.3.2 | 2,435 | 11/21/2021 | |
3.3.1 | 2,640 | 11/21/2021 | |
3.3.0 | 2,899 | 11/19/2021 | |
3.2.0 | 3,874 | 11/9/2021 | |
3.1.7 | 5,157 | 10/20/2021 | |
3.1.6 | 2,953 | 10/15/2021 | |
3.1.5 | 2,190 | 10/15/2021 | |
3.1.4 | 3,831 | 10/13/2021 | |
3.1.3 | 1,409 | 10/12/2021 | |
3.1.2 | 2,231 | 10/12/2021 | |
3.1.1 | 4,200 | 9/23/2021 | |
3.1.0 | 3,211 | 9/21/2021 | |
3.0.3 | 2,115 | 9/15/2021 | |
3.0.2 | 4,280 | 9/13/2021 | |
3.0.1 | 1,175 | 8/25/2021 | |
3.0.1-pre | 1,879 | 8/8/2021 | |
3.0.0 | 7,943 | 8/24/2021 | |
3.0.0-pre | 672 | 8/5/2021 | |
2.4.6 | 4,205 | 7/17/2021 | |
2.4.5 | 1,914 | 7/11/2021 | |
2.4.4 | 1,958 | 7/11/2021 | |
2.4.3 | 3,226 | 7/7/2021 | |
2.4.2 | 1,642 | 7/6/2021 | |
2.4.1 | 2,892 | 7/3/2021 | |
2.4.0 | 3,315 | 7/3/2021 | |
2.3.9-pre | 626 | 6/1/2021 | |
2.3.9-dev | 502 | 7/2/2021 | |
2.3.8 | 2,772 | 5/30/2021 | |
2.3.8-pre-dev | 369 | 5/30/2021 | |
2.3.8-pre | 396 | 5/30/2021 | |
2.3.7 | 1,035 | 5/30/2021 | |
2.3.6 | 2,247 | 5/30/2021 | |
2.3.5 | 1,643 | 5/29/2021 | |
2.3.5-dev | 999 | 5/29/2021 | |
2.3.4 | 2,887 | 5/28/2021 | |
2.3.2 | 649 | 5/27/2021 | |
2.3.1 | 2,225 | 5/27/2021 | |
2.3.1-dev | 333 | 5/27/2021 |