Discord.Net.Labs.Webhook
2.3.4
See the version list below for details.
dotnet add package Discord.Net.Labs.Webhook --version 2.3.4
NuGet\Install-Package Discord.Net.Labs.Webhook -Version 2.3.4
<PackageReference Include="Discord.Net.Labs.Webhook" Version="2.3.4" />
paket add Discord.Net.Labs.Webhook --version 2.3.4
#r "nuget: Discord.Net.Labs.Webhook, 2.3.4"
// Install Discord.Net.Labs.Webhook as a Cake Addin #addin nuget:?package=Discord.Net.Labs.Webhook&version=2.3.4 // Install Discord.Net.Labs.Webhook as a Cake Tool #tool nuget:?package=Discord.Net.Labs.Webhook&version=2.3.4
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 Playwo's InteractivityAddon. The reason is that his package depends on the base discord.net lib, you can get around this by cloning his repo and building it with discord.net labs instead of discord.net.
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 arg)
{
switch (arg.Type) // We want to check the type of this interaction
{
//Slash commands
case InteractionType.ApplicationCommand:
await MySlashCommandHandler(arg);
break;
//Button clicks/selection dropdowns
case InteractionType.MessageComponent:
await MyMessageComponentHandler(arg);
break;
//Unused
case InteractionType.Ping:
break;
//Unknown/Unsupported
default:
Console.WriteLine("Unsupported interaction type: " + arg.Type);
break;
}
}
Handling button clicks and selection dropdowns
private async Task MyMessageComponentHandler(SocketInteraction arg)
{
// Parse the arg
var parsedArg = (SocketMessageComponent) arg;
// Get the custom ID
var customId = parsedArg.Data.CustomId;
// Get the user
var user = (SocketGuildUser) arg.User;
// Get the guild
var guild = user.Guild;
// Respond with the update message response type. This edits the original message if you have set AlwaysAcknowledgeInteractions to false.
// You can also use "ephemeral" so that only the original user of the interaction sees the message
await parsedArg.RespondAsync($"Clicked {parsedArg.Data.CustomId}!", type: InteractionResponseType.UpdateMessage, ephemeral: true);
// You can also followup with a second message
await parsedArg.FollowupAsync($"Clicked {parsedArg.Data.CustomId}!", type: InteractionResponseType.ChannelMessageWithSource, ephemeral: true);
//If you are using selection dropdowns, you can get the selected label and values using these:
var selectedLabel = ((SelectMenu) parsedArg.Message.Components.First().Components.First()).Options.FirstOrDefault(x => x.Value == parsedArg.Data.Values.FirstOrDefault())?.Label;
var selectedValue = parsedArg.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")
.WithLabel("Select menu!")
.WithPlaceholder("This is a placeholder")
.WithOptions(new List<SelectMenuOptionBuilder>()
{
new SelectMenuOptionBuilder()
.WithLabel("Option A")
.WithEmote(Emote.Parse("<:evanpog:810017136814194698>"))
.WithDescription("Evan pog champ")
.WithValue("value1"),
new SelectMenuOptionBuilder()
.WithLabel("Option B")
.WithDescription("Option B is poggers")
.WithValue("value2")
}));
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
Slash command example how to's can be found here. If you want to read some code using slash commands, you can do that 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 was computed. 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. |
-
.NETStandard 2.0
- Discord.Net.Labs.Core (>= 2.4.0)
- Discord.Net.Labs.Rest (>= 2.4.0)
-
.NETStandard 2.1
- Discord.Net.Labs.Core (>= 2.4.0)
- Discord.Net.Labs.Rest (>= 2.4.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Discord.Net.Labs.Webhook:
Package | Downloads |
---|---|
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. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
3.6.1 | 23,964 | 12/24/2021 | |
3.6.0 | 820 | 12/24/2021 | |
3.5.0 | 598 | 12/15/2021 | |
3.4.9 | 4,539 | 12/6/2021 | |
3.4.8 | 5,474 | 12/4/2021 | |
3.4.7 | 3,127 | 11/28/2021 | |
3.4.6 | 867 | 11/27/2021 | |
3.4.5 | 702 | 11/27/2021 | |
3.4.4 | 745 | 11/27/2021 | |
3.4.3 | 747 | 11/27/2021 | |
3.4.2 | 2,654 | 11/26/2021 | |
3.4.1 | 2,149 | 11/26/2021 | |
3.4.0 | 2,215 | 11/26/2021 | |
3.3.3 | 1,068 | 11/23/2021 | |
3.3.2 | 1,340 | 11/21/2021 | |
3.3.1 | 1,506 | 11/21/2021 | |
3.3.0 | 1,775 | 11/19/2021 | |
3.2.0 | 2,052 | 11/9/2021 | |
3.1.7 | 3,769 | 10/20/2021 | |
3.1.6 | 1,662 | 10/15/2021 | |
3.1.5 | 592 | 10/15/2021 | |
3.1.4 | 1,448 | 10/13/2021 | |
3.1.2 | 1,703 | 10/12/2021 | |
3.0.0 | 11,404 | 8/24/2021 | |
3.0.0-pre | 401 | 8/8/2021 | |
2.3.4 | 5,321 | 7/3/2021 | |
2.3.3 | 1,561 | 5/30/2021 | |
2.3.2 | 1,024 | 5/30/2021 | |
2.3.1 | 2,188 | 5/27/2021 |