diff --git a/README.md b/README.md index 34a42c036..7dba539e4 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ # Table of Contents 1. [📦 Installation](#1--installation) -2. [🚀 Example](#2--example) +2. [🚀 Showcase](#2--showcase) 3. [🎨 Features](#3--features) 4. [🥅 Goals](#4--goals) 5. [📚 Guides](#5--guides) @@ -32,12 +32,12 @@ You can install NetCord packages via NuGet package manager: | **[NetCord.Hosting.Services](https://www.nuget.org/packages/NetCord.Hosting.Services)** | Provides .NET Generic Host extensions for the NetCord.Services package. | | **[NetCord.Hosting.AspNetCore](https://www.nuget.org/packages/NetCord.Hosting.AspNetCore)** | Provides ASP.NET Core extensions for seamless handling of HTTP interactions. | -## 2. 🚀 Example +## 2. 🚀 Showcase -This snippet showcases a Discord bot with a minimal API-style `/ping` command responding with `Pong!`. +This snippet showcases a bot with a minimal API-style `/square` command and includes a module-based `/greet` command.
-Usings omitted for readability, click here to show +Required usings omitted for readability, click here to show ```cs using Microsoft.Extensions.Hosting; @@ -50,18 +50,34 @@ using NetCord.Hosting.Services.ApplicationCommands;
+### Minimal API-style Bot Example + +The following example sets up a bot with a minimal API-style approach for the `/square` command, which calculates the square of a number: + ```cs var builder = Host.CreateDefaultBuilder(args) .UseDiscordGateway() .UseApplicationCommands(); var host = builder.Build() - .AddSlashCommand("ping", "Ping!", () => "Pong!") + .AddSlashCommand("square", "Square!", (int a) => $"{a}² = {a * a}") .UseGatewayEventHandlers(); await host.RunAsync(); ``` +### Module-based Command Example + +Moreover, you can use a module-based approach. Here's an example of a `/greet` command that greets a specified user: + +```cs +public class GreetingModule : ApplicationCommandModule +{ + [SlashCommand("greet", "Greet someone!")] + public string Greet(User user) => $"{Context.User} greets {user}!"; +} +``` + ## 3. 🎨 Features - **Fully customizable** - NetCord is fully customizable and extensible