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" />
                    
Directory.Packages.props
<PackageReference Include="PawSharp.Interactions" />
                    
Project file
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
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=PawSharp.Interactions&version=1.1.0-alpha.5.ci.10&prerelease
                    
Install as a Cake Tool

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.Client
  • PawSharp.API
  • PawSharp.Gateway
  • PawSharp.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 interactions
  • ChannelMessageWithSource: Send a message response
  • DeferredChannelMessageWithSource: Defer with loading state
  • UpdateMessage: Update the component's message
  • DeferredUpdateMessage: Defer component update without loading state
  • ApplicationCommandAutocompleteResult: Send autocomplete choices
  • Modal: Show a modal dialog
  • PremiumRequired: 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 URLs
  • SelectMenuBuilder: Create string select menus with options
  • UserSelectMenuBuilder: Select from guild users
  • RoleSelectMenuBuilder: Select from guild roles
  • MentionableSelectMenuBuilder: Select from users and roles
  • ChannelSelectMenuBuilder: Select from channels with type filtering
  • ActionRowBuilder: Container for up to 5 components
  • ModalBuilder: Create modal dialogs with text inputs
Components v2
  • LabelBuilder: Display text with optional emoji
  • TextDisplayBuilder: Render markdown text
  • ThumbnailBuilder: Display images as accessories
  • MediaGalleryBuilder: Display collections of media
  • FileBuilder: Render file attachments
  • SeparatorBuilder: Add visual dividers
  • ContainerBuilder: Top-level container with accent colors
  • SectionBuilder: Group text displays with accessories
  • FileUploadBuilder: Allow file uploads in modals
  • RadioGroupBuilder: Single-select option groups
  • CheckboxGroupBuilder: Multi-select option groups
  • CheckboxBuilder: 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
        }
    });
});
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
  • PawSharp.Client: recommended host for interaction handlers
  • PawSharp.Commands: prefix command workflows
  • PawSharp.Interactivity: user-response waiters and paginated UX
  • PawSharp.API: REST API client for Discord
  • PawSharp.Gateway: WebSocket gateway client
  • PawSharp.Core: Shared entities and enums

Documentation

Support

License

MIT. See ../../LICENSE.

Product 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.

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