PawSharp.Interactions 0.11.0-alpha.1

This is a prerelease version of PawSharp.Interactions.
dotnet add package PawSharp.Interactions --version 0.11.0-alpha.1
                    
NuGet\Install-Package PawSharp.Interactions -Version 0.11.0-alpha.1
                    
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="0.11.0-alpha.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PawSharp.Interactions" Version="0.11.0-alpha.1" />
                    
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 0.11.0-alpha.1
                    
#r "nuget: PawSharp.Interactions, 0.11.0-alpha.1"
                    
#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@0.11.0-alpha.1
                    
#: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=0.11.0-alpha.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PawSharp.Interactions&version=0.11.0-alpha.1&prerelease
                    
Install as a Cake Tool

PawSharp.Interactions

Slash commands and component interactions for Discord bots.

PawSharp.Interactions provides a complete framework for handling Discord's modern interaction system, including slash commands, buttons, select menus, and modal dialogs.

Features

  • Slash command registration and handling
  • Component interaction support (buttons, select menus)
  • Automatic interaction response handling
  • Followup message support
  • Modal dialog handling
  • Type-safe interaction data parsing
  • Permission checking for commands
  • Fully typed component hierarchy � ActionRow, Button, SelectMenu variants, TextInput
  • ModalBuilder with fluent AddTextInput(label, customId, TextInputStyle, �) API

Installation

dotnet add package PawSharp.Interactions --version 0.10.0-alpha.3

Quick Start

using PawSharp.Client;
using PawSharp.Interactions;

// Create Discord client
var client = new DiscordClient(new PawSharpOptions { Token = "your-token" });

// Enable interactions
var interactions = client.UseInteractions();

// Handle slash commands
interactions.OnInteractionCreate += async (interaction) =>
{
    if (interaction.Type == InteractionType.ApplicationCommand)
    {
        var commandData = interaction.Data as ApplicationCommandInteractionData;
        if (commandData?.Name == "ping")
        {
            await interaction.RespondAsync("Pong!");
        }
    }
};

// Register slash commands
await client.Rest.CreateGuildApplicationCommandAsync(guildId, new ApplicationCommand
{
    Name = "ping",
    Description = "Responds with pong",
    Type = ApplicationCommandType.ChatInput
});

Interaction Types

Slash Commands

interactions.OnInteractionCreate += async (interaction) =>
{
    if (interaction.Type == InteractionType.ApplicationCommand)
    {
        var data = interaction.Data as ApplicationCommandInteractionData;
        switch (data?.Name)
        {
            case "ping":
                await interaction.RespondAsync("Pong!");
                break;
            case "echo":
                var text = data.Options?.FirstOrDefault()?.Value as string;
                await interaction.RespondAsync(text);
                break;
        }
    }
};

Button Interactions

interactions.OnInteractionCreate += async (interaction) =>
{
    if (interaction.Type == InteractionType.MessageComponent)
    {
        var data = interaction.Data as MessageComponentInteractionData;
        if (data?.ComponentType == ComponentType.Button)
        {
            switch (data.CustomId)
            {
                case "primary_button":
                    await interaction.RespondAsync("Primary button clicked!");
                    break;
                case "secondary_button":
                    await interaction.UpdateMessageAsync("Secondary button clicked!");
                    break;
            }
        }
    }
};

Select Menu Interactions

interactions.OnInteractionCreate += async (interaction) =>
{
    if (interaction.Type == InteractionType.MessageComponent)
    {
        var data = interaction.Data as MessageComponentInteractionData;
        if (data?.ComponentType == ComponentType.SelectMenu)
        {
            var selectedValue = data.Values?.FirstOrDefault();
            await interaction.RespondAsync($"You selected: {selectedValue}");
        }
    }
};
// Build a modal using the fluent ModalBuilder
var modal = new ModalBuilder()
    .WithCustomId("feedback_modal")
    .WithTitle("Share your feedback")
    .AddTextInput("Your name",     "name_input",     TextInputStyle.Short,     placeholder: "Jane Doe")
    .AddTextInput("Your feedback", "feedback_input",  TextInputStyle.Paragraph, minLength: 10, maxLength: 500)
    .Build();

await interaction.RespondWithModalAsync(modal);

Note (alpha13 breaking change): AddTextInput now accepts TextInputStyle instead of int for the style parameter. Replace style: 1 / style: 2 with TextInputStyle.Short / TextInputStyle.Paragraph.

EmbedBuilder

using PawSharp.Core.Builders;

var embed = new EmbedBuilder()
    .WithTitle("Result")
    .WithDescription("Operation completed successfully.")
    .WithColor(0x57F287) // green
    .AddField("Duration", "42 ms", inline: true)
    .WithFooter("PawSharp")
    .WithTimestamp()
    .Build();

await interaction.RespondAsync(embed: embed);

Typed Components

Components received in interactions are now fully typed:

// Message.Components is List<MessageComponent>? � deserializes automatically
foreach (var row in message.Components ?? [])
{
    if (row is ActionRow actionRow)
    {
        foreach (var component in actionRow.Components)
        {
            if (component is Button btn)
                Console.WriteLine($"Button: {btn.Label} ({btn.Style})");
            else if (component is SelectMenu menu)
                Console.WriteLine($"Select: {menu.CustomId}, options: {menu.Options.Count}");
        }
    }
}

Response Types

Immediate Response

// Respond immediately (within 3 seconds)
await interaction.RespondAsync("Quick response!");

Deferred Response

// Defer response for later
await interaction.DeferAsync();

// Do some work...
await Task.Delay(2000);

// Send followup
await interaction.FollowupAsync("Deferred response!");

Update Message

// Update the original message (for components)
await interaction.UpdateMessageAsync("Message updated!");

Command Registration

Global Commands

var command = new ApplicationCommand
{
    Name = "globalcommand",
    Description = "A global slash command",
    Type = ApplicationCommandType.ChatInput
};

await client.Rest.CreateGlobalApplicationCommandAsync(command);

Guild Commands

var command = new ApplicationCommand
{
    Name = "guildcommand",
    Description = "A guild-specific slash command",
    Type = ApplicationCommandType.ChatInput,
    Options = new[]
    {
        new ApplicationCommandOption
        {
            Name = "text",
            Description = "Text to echo",
            Type = ApplicationCommandOptionType.String,
            Required = true
        }
    }
};

await client.Rest.CreateGuildApplicationCommandAsync(guildId, command);

Permission Management

// Set command permissions
var permissions = new ApplicationCommandPermissions
{
    Permissions = new[]
    {
        new ApplicationCommandPermission
        {
            Id = roleId,
            Type = ApplicationCommandPermissionType.Role,
            Permission = true
        }
    }
};

await client.Rest.EditApplicationCommandPermissionsAsync(applicationId, guildId, commandId, permissions);

Dependencies

  • PawSharp.Core - Entity models
  • PawSharp.Client - Discord client integration
  • .NET 8.0 - Modern runtime
  • PawSharp.Client - Main client
  • PawSharp.Commands - Traditional commands

License

MIT License - see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
0.11.0-alpha.1 36 3/10/2026
0.10.0-alpha.3 39 3/8/2026
0.7.0-alpha.1 39 3/6/2026
0.6.1-alpha1 47 3/4/2026
0.6.0-alpha1 43 2/25/2026
0.5.0-alpha9 52 1/15/2026
0.5.0-alpha8 69 1/14/2026
0.5.0-alpha13 51 2/22/2026
0.5.0-alpha12 53 2/22/2026
0.5.0-alpha11 66 2/20/2026