PawSharp.Interactions
1.1.0-alpha.5.ci.10
This is a prerelease version of PawSharp.Interactions.
dotnet add package PawSharp.Interactions --version 1.1.0-alpha.5.ci.10
NuGet\Install-Package PawSharp.Interactions -Version 1.1.0-alpha.5.ci.10
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PawSharp.Interactions" Version="1.1.0-alpha.5.ci.10" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PawSharp.Interactions" Version="1.1.0-alpha.5.ci.10" />
<PackageReference Include="PawSharp.Interactions" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PawSharp.Interactions --version 1.1.0-alpha.5.ci.10
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PawSharp.Interactions, 1.1.0-alpha.5.ci.10"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PawSharp.Interactions@1.1.0-alpha.5.ci.10
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PawSharp.Interactions&version=1.1.0-alpha.5.ci.10&prerelease
#tool nuget:?package=PawSharp.Interactions&version=1.1.0-alpha.5.ci.10&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PawSharp.Interactions
PawSharp.Interactions brings Discord's modern interaction model into your bot workflow.
Use it for slash commands, button/select interactions, and modal submissions with a clean structure that stays maintainable as your command surface grows.
Why Use This Package
- Slash command and component interaction handling
- Support for modals and follow-up responses
- Strongly typed interaction data
- Clean extension workflow with PawSharp.Client
- Webhook signature verification for HTTP interactions
- Full support for Components v2 (Labels, RadioGroups, CheckboxGroups, etc.)
Requirements
- .NET 10 (
net10.0) PawSharp.ClientPawSharp.APIPawSharp.GatewayPawSharp.Core
Installation
dotnet add package PawSharp.Interactions --version 1.1.0-alpha.4
Quick Start
using PawSharp.Interactions;
var interactions = client.UseInteractions();
interactions.OnInteractionCreate += async interaction =>
{
if (interaction.Type == InteractionType.ApplicationCommand)
{
await interaction.RespondAsync("Interaction received.");
}
};
Features
Interaction Types
- ApplicationCommand: Slash commands, user context menus, message context menus
- MessageComponent: Buttons, select menus (string, user, role, mentionable, channel)
- ModalSubmit: Modal form submissions
- ApplicationCommandAutocomplete: Autocomplete suggestions for slash commands
Response Types
Pong: Respond to ping interactionsChannelMessageWithSource: Send a message responseDeferredChannelMessageWithSource: Defer with loading stateUpdateMessage: Update the component's messageDeferredUpdateMessage: Defer component update without loading stateApplicationCommandAutocompleteResult: Send autocomplete choicesModal: Show a modal dialogPremiumRequired: Show premium upgrade button (deprecated)LaunchActivity: Launch a Discord Activity
Component Builders
The package includes fluent builders for all Discord component types:
Basic Components
ButtonBuilder: Create buttons with styles, emojis, and URLsSelectMenuBuilder: Create string select menus with optionsUserSelectMenuBuilder: Select from guild usersRoleSelectMenuBuilder: Select from guild rolesMentionableSelectMenuBuilder: Select from users and rolesChannelSelectMenuBuilder: Select from channels with type filteringActionRowBuilder: Container for up to 5 componentsModalBuilder: Create modal dialogs with text inputs
Components v2
LabelBuilder: Display text with optional emojiTextDisplayBuilder: Render markdown textThumbnailBuilder: Display images as accessoriesMediaGalleryBuilder: Display collections of mediaFileBuilder: Render file attachmentsSeparatorBuilder: Add visual dividersContainerBuilder: Top-level container with accent colorsSectionBuilder: Group text displays with accessoriesFileUploadBuilder: Allow file uploads in modalsRadioGroupBuilder: Single-select option groupsCheckboxGroupBuilder: Multi-select option groupsCheckboxBuilder: Single toggleable checkbox
Usage Examples
Slash Command Handler
var handler = new InteractionHandler(restClient, logger);
handler.RegisterCommand("ping", async interaction =>
{
await handler.RespondEphemeralAsync(interaction.Id, interaction.Token, "Pong!");
});
await handler.HandleInteractionAsync(interactionEvent);
Button Click Handler
handler.RegisterComponent("confirm_button", async interaction =>
{
await handler.RespondAsync(interaction.Id, interaction.Token, new InteractionResponse
{
Type = (int)InteractionResponseType.ChannelMessageWithSource,
Data = new InteractionCallbackData
{
Content = "Button clicked!",
Flags = 64 // Ephemeral
}
});
});
Modal Submission Handler
handler.RegisterModal("feedback_modal", async interaction =>
{
var feedback = interaction.GetModalValue("feedback_input");
await handler.RespondEphemeralAsync(interaction.Id, interaction.Token,
$"Thanks for your feedback: {feedback}");
});
Creating a Modal
var modal = new ModalBuilder()
.WithCustomId("feedback_modal")
.WithTitle("Feedback")
.AddTextInput("Your Feedback", "feedback_input",
TextInputStyle.Paragraph, placeholder: "Share your thoughts...")
.BuildResponse();
await handler.RespondAsync(interaction.Id, interaction.Token, modal);
Building Buttons with ActionRow
var response = new InteractionResponseBuilder()
.WithContent("Choose an option:")
.AddActionRow(row =>
{
row.AddButton(new ButtonBuilder("accept", "Accept", ButtonStyle.Success));
row.AddButton(new ButtonBuilder("decline", "Decline", ButtonStyle.Danger));
})
.AsEphemeral()
.Build();
await handler.RespondAsync(interaction.Id, interaction.Token, response);
Using Extension Methods
// Get option values from slash commands
var userId = interaction.GetOptionValue<ulong>("user");
var reason = interaction.GetOptionValue<string>("reason");
// Get subcommand name
var subcommand = interaction.GetSubcommandName();
// Check interaction context
if (interaction.IsGuildInteraction())
{
// Handle guild interaction
}
// Get modal values
var feedback = interaction.GetModalValue("feedback_input");
var allValues = interaction.GetModalValues();
Follow-up Messages
// Send a follow-up message
var followup = await handler.CreateFollowupAsync(applicationId, interactionToken,
new CreateMessageRequest { Content = "Additional info" });
// Edit the follow-up
await handler.EditFollowupAsync(applicationId, interactionToken, followup.Id,
new EditMessageRequest { Content = "Updated info" });
// Delete the follow-up
await handler.DeleteFollowupAsync(applicationId, interactionToken, followup.Id);
Webhook Verification (HTTP Interactions)
var verifier = new WebhookVerifier("your_public_key_hex");
// In your HTTP endpoint
var signature = Request.Headers["X-Signature-Ed25519"];
var timestamp = Request.Headers["X-Signature-Timestamp"];
var body = await new StreamReader(Request.Body).ReadToEndAsync();
if (!verifier.Verify(signature, timestamp, body))
{
return StatusCode(401);
}
// Process the interaction
Autocomplete Handler
handler.RegisterAutocomplete("search", async interaction =>
{
var query = interaction.GetOptionValue<string>("query");
var choices = new List<AutocompleteChoice>
{
new AutocompleteChoice { Name = "Option 1", Value = "opt1" },
new AutocompleteChoice { Name = "Option 2", Value = "opt2" }
};
return choices;
});
Context Menu Handlers
// User context menu (right-click on user)
handler.RegisterUserContextMenu("Ban User", async interaction =>
{
var targetId = interaction.Data?.TargetId;
// Handle ban logic
});
// Message context menu (right-click on message)
handler.RegisterMessageContextMenu("Pin Message", async interaction =>
{
var targetId = interaction.Data?.TargetId;
// Handle pin logic
});
Dependency Injection
// In ConfigureServices
services.AddInteractionHandler();
// Inject into your service
public class MyService
{
private readonly InteractionHandler _handler;
public MyService(InteractionHandler handler)
{
_handler = handler;
}
}
Typical Use Cases
- Slash-first bot command experiences
- Rich UI flows with buttons, menus, and modals
- Hybrid bots using both commands and interactions
- HTTP-based interaction endpoints with webhook verification
- Context menu integrations for users and messages
Related Packages
PawSharp.Client: recommended host for interaction handlersPawSharp.Commands: prefix command workflowsPawSharp.Interactivity: user-response waiters and paginated UXPawSharp.API: REST API client for DiscordPawSharp.Gateway: WebSocket gateway clientPawSharp.Core: Shared entities and enums
Documentation
- Main repository guide: ../../README.md
- Package source: ./
Support
- Join the PawSharp Discord for help, discussion, and community.
- Report bugs or request features via GitHub Issues.
- Start a discussion on GitHub Discussions.
License
MIT. See ../../LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- PawSharp.API (>= 1.1.0-alpha.5.ci.10)
- PawSharp.Core (>= 1.1.0-alpha.5.ci.10)
- PawSharp.Gateway (>= 1.1.0-alpha.5.ci.10)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on PawSharp.Interactions:
| Package | Downloads |
|---|---|
|
PawSharp.Client
Main Discord client for PawSharp with unified API, gateway, and caching. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.0-alpha.5.ci.10 | 128 | 7/14/2026 |
| 1.1.0-alpha.5 | 97 | 7/14/2026 |
| 1.1.0-alpha.4.ci.9 | 109 | 6/29/2026 |
| 1.1.0-alpha.4 | 107 | 6/29/2026 |
| 1.1.0-alpha.3 | 101 | 6/15/2026 |
| 1.1.0-alpha.2.ci.7 | 94 | 5/4/2026 |
| 1.1.0-alpha.2 | 91 | 5/4/2026 |
| 1.0.0-alpha.4.ci.4 | 100 | 4/27/2026 |
| 1.0.0-alpha.4 | 96 | 4/23/2026 |
| 1.0.0-alpha.2.ci.3 | 90 | 4/15/2026 |
| 1.0.0-alpha.2 | 90 | 4/9/2026 |
| 0.11.0-alpha.1 | 105 | 3/10/2026 |
| 0.10.0-alpha.3 | 86 | 3/8/2026 |
| 0.7.0-alpha.1 | 90 | 3/6/2026 |
| 0.6.1-alpha1 | 99 | 3/4/2026 |
| 0.6.0-alpha1 | 93 | 2/25/2026 |
| 0.5.0-alpha13 | 98 | 2/22/2026 |
| 0.5.0-alpha12 | 99 | 2/22/2026 |
| 0.5.0-alpha11 | 108 | 2/20/2026 |
Loading failed