PawSharp.Commands 0.11.0-alpha.1

This is a prerelease version of PawSharp.Commands.
dotnet add package PawSharp.Commands --version 0.11.0-alpha.1
                    
NuGet\Install-Package PawSharp.Commands -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.Commands" 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.Commands" Version="0.11.0-alpha.1" />
                    
Directory.Packages.props
<PackageReference Include="PawSharp.Commands" />
                    
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.Commands --version 0.11.0-alpha.1
                    
#r "nuget: PawSharp.Commands, 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.Commands@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.Commands&version=0.11.0-alpha.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PawSharp.Commands&version=0.11.0-alpha.1&prerelease
                    
Install as a Cake Tool

PawSharp.Commands

Modern command framework for Discord bots with attribute-based registration and async support.

PawSharp.Commands provides a clean, extensible command system for Discord bots. Built with modern .NET patterns, it supports async operations, dependency injection, and modular command organization.

Features

  • Attribute-based command registration
  • Full async/await support with RegisterModuleAsync()
  • Automatic command enumeration with GetRegisteredCommands()
  • Smart argument parsing with type conversion
  • Modular command organization
  • Alias support for commands
  • Execution hooks (before/after)
  • Dependency injection in command modules
  • Strongly-typed command contexts

?? Installation

dotnet add package PawSharp.Commands --version 0.6.1-alpha1

?? Quick Start

using PawSharp.Client;
using PawSharp.Commands.Extensions;

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

// Enable commands with prefix
var commands = client.UseCommands("!");

// Create a command module
public class GeneralCommands : BaseCommandModule
{
    [Command("ping")]
    [Description("Check bot latency")]
    public async Task PingAsync(CommandContext ctx)
    {
        await ctx.RespondAsync("Pong! ??");
    }

    [Command("echo")]
    [Aliases("say", "repeat")]
    [Description("Echo back the provided text")]
    public async Task EchoAsync(CommandContext ctx, string text)
    {
        await ctx.RespondAsync(text);
    }

    [Command("userinfo")]
    [Description("Get information about a user")]
    public async Task UserInfoAsync(CommandContext ctx, User? user = null)
    {
        user ??= ctx.User;
        await ctx.RespondAsync($"User: {user.Username}#{user.Discriminator}");
    }
}

// Register the module
await commands.RegisterModuleAsync(client, new GeneralCommands());

?? Command Registration

Basic Commands

[Command("greet")]
public async Task GreetAsync(CommandContext ctx)
{
    await ctx.RespondAsync($"Hello, {ctx.User.Username}!");
}

Commands with Parameters

[Command("ban")]
[Description("Ban a user from the guild")]
public async Task BanAsync(CommandContext ctx, User user, string reason = "No reason provided")
{
    // Implementation here
    await ctx.RespondAsync($"Banned {user.Username} for: {reason}");
}

Commands with Aliases

[Command("avatar")]
[Aliases("pfp", "profilepic")]
[Description("Get a user's avatar")]
public async Task AvatarAsync(CommandContext ctx, User? user = null)
{
    user ??= ctx.User;
    await ctx.RespondAsync(user.AvatarUrl);
}

?? Advanced Features

Async Module Initialization

public class DatabaseCommands : BaseCommandModule
{
    private readonly MyDatabaseService _database;

    public DatabaseCommands(MyDatabaseService database)
    {
        _database = database;
    }

    public override async Task InitializeAsync()
    {
        // Load command data from database
        await _database.ConnectAsync();
        await base.InitializeAsync();
    }

    [Command("stats")]
    public async Task StatsAsync(CommandContext ctx)
    {
        var stats = await _database.GetStatsAsync();
        await ctx.RespondAsync($"Total users: {stats.UserCount}");
    }
}

Command Discovery

// Get all registered commands
var registeredCommands = commands.GetRegisteredCommands();

foreach (var cmd in registeredCommands)
{
    Console.WriteLine($"{cmd.Name}: {cmd.Description}");
    if (cmd.Aliases.Any())
    {
        Console.WriteLine($"  Aliases: {string.Join(", ", cmd.Aliases)}");
    }
}

Execution Hooks

public class LoggingModule : BaseCommandModule
{
    public override async Task BeforeExecuteAsync(CommandContext ctx)
    {
        Console.WriteLine($"{ctx.User.Username} executed: {ctx.CommandName}");
        await base.BeforeExecuteAsync(ctx);
    }

    public override async Task AfterExecuteAsync(CommandContext ctx)
    {
        Console.WriteLine($"Command {ctx.CommandName} completed");
        await base.AfterExecuteAsync(ctx);
    }
}

?? Command Context

The CommandContext provides access to:

public async Task ExampleAsync(CommandContext ctx)
{
    // Message information
    var message = ctx.Message;
    var channel = ctx.Channel;
    var guild = ctx.Guild;

    // User information
    var user = ctx.User;
    var member = ctx.Member;

    // Command information
    var commandName = ctx.CommandName;
    var rawArgs = ctx.RawArguments;
    var parsedArgs = ctx.Arguments;

    // Response methods
    await ctx.RespondAsync("Reply to the user");
    await ctx.RespondDMAsync("Send a DM");
}

?? Dependency Injection

// Register services
services.AddSingleton<MyService>();

// Inject into command modules
public class MyCommands : BaseCommandModule
{
    private readonly MyService _service;

    public MyCommands(MyService service)
    {
        _service = service;
    }

    [Command("service")]
    public async Task UseServiceAsync(CommandContext ctx)
    {
        var result = await _service.DoSomethingAsync();
        await ctx.RespondAsync(result);
    }
}

?? Configuration

// Configure command system
var commands = client.UseCommands(new CommandConfiguration
{
    Prefix = "!",
    CaseSensitive = false,
    EnableMentionPrefix = true,
    IgnoreBots = true,
    RequiredPermissions = Permissions.UseSlashCommands
});

??? Error Handling

public class ErrorHandlingModule : BaseCommandModule
{
    public override async Task OnErrorAsync(CommandContext ctx, Exception ex)
    {
        await ctx.RespondAsync($"? An error occurred: {ex.Message}");
        await base.OnErrorAsync(ctx, ex);
    }
}

?? Dependencies

  • PawSharp.Client - Discord client integration
  • PawSharp.Core - Entity models
  • .NET 8.0 - Modern runtime
  • Microsoft.Extensions.DependencyInjection - DI container

?? 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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.11.0-alpha.1 32 3/10/2026
0.10.0-alpha.3 40 3/8/2026
0.7.0-alpha.1 37 3/6/2026
0.6.1-alpha1 36 3/4/2026
0.6.0-alpha1 41 2/25/2026
0.5.0-alpha9 60 1/15/2026
0.5.0-alpha8 54 1/14/2026
0.5.0-alpha13 42 2/22/2026
0.5.0-alpha12 45 2/22/2026
0.5.0-alpha11 46 2/20/2026