From 56fd60311199f2353cb329c1871c99f039d5716d Mon Sep 17 00:00:00 2001 From: Kuba_Z2 <77853483+KubaZ2@users.noreply.github.com> Date: Mon, 8 Jul 2024 12:47:48 +0200 Subject: [PATCH 1/7] Improve the showcase in readme --- README.md | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 34a42c036..318966cc4 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,16 +32,15 @@ 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 `/sum` 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; - using NetCord; using NetCord.Services.ApplicationCommands; using NetCord.Hosting.Gateway; @@ -50,18 +49,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 `/sum` command, which calculates the sum of two numbers: + ```cs var builder = Host.CreateDefaultBuilder(args) .UseDiscordGateway() .UseApplicationCommands(); var host = builder.Build() - .AddSlashCommand("ping", "Ping!", () => "Pong!") + .AddSlashCommand("sum", "Sum numbers!", (decimal a, decimal b) => $"{a} + {b} = {a + b}") .UseGatewayEventHandlers(); await host.RunAsync(); ``` +### Module-based Command Example + +Moreover, you can enhance your bot with module-based commands. 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 From 835110e4823cc6947b6319ddaf31372046d91771 Mon Sep 17 00:00:00 2001 From: Kuba_Z2 <77853483+KubaZ2@users.noreply.github.com> Date: Mon, 8 Jul 2024 15:44:35 +0200 Subject: [PATCH 2/7] Improve another time --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 318966cc4..9a378fbb3 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ await host.RunAsync(); ### Module-based Command Example -Moreover, you can enhance your bot with module-based commands. Here's an example of a `/greet` command that greets a specified user: +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 From 0eb2a071998f911e7015622e16337e18e1224231 Mon Sep 17 00:00:00 2001 From: Kuba_Z2 <77853483+KubaZ2@users.noreply.github.com> Date: Mon, 8 Jul 2024 15:45:25 +0200 Subject: [PATCH 3/7] Add a new line in usings --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9a378fbb3..35e92454f 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ This snippet showcases a bot with a minimal API-style `/sum` command and include ```cs using Microsoft.Extensions.Hosting; + using NetCord; using NetCord.Services.ApplicationCommands; using NetCord.Hosting.Gateway; From 51715f0789726f6defa93116a5959fec3012ecec Mon Sep 17 00:00:00 2001 From: Kuba_Z2 <77853483+KubaZ2@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:00:06 +0200 Subject: [PATCH 4/7] Shorten a long line --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35e92454f..53f7f3355 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ var builder = Host.CreateDefaultBuilder(args) .UseApplicationCommands(); var host = builder.Build() - .AddSlashCommand("sum", "Sum numbers!", (decimal a, decimal b) => $"{a} + {b} = {a + b}") + .AddSlashCommand("sum", "Sum!", (int a, int b) => $"{a} + {b} = {a + b}") .UseGatewayEventHandlers(); await host.RunAsync(); From c55f163f3f55500734d4bff95eb6fac7e5fbdf33 Mon Sep 17 00:00:00 2001 From: Kuba_Z2 <77853483+KubaZ2@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:01:18 +0200 Subject: [PATCH 5/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 53f7f3355..00ac294d8 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ var builder = Host.CreateDefaultBuilder(args) .UseApplicationCommands(); var host = builder.Build() - .AddSlashCommand("sum", "Sum!", (int a, int b) => $"{a} + {b} = {a + b}") + .AddSlashCommand("sum", "Sum", (int a, int b) => $"{a} + {b} = {a + b}") .UseGatewayEventHandlers(); await host.RunAsync(); From f9820b0a19c3ad28ac8570aead86bebd7485b32f Mon Sep 17 00:00:00 2001 From: Kuba_Z2 <77853483+KubaZ2@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:17:19 +0200 Subject: [PATCH 6/7] /square instead of /sum --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 00ac294d8..cc6dc101b 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ You can install NetCord packages via NuGet package manager: ## 2. 🚀 Showcase -This snippet showcases a bot with a minimal API-style `/sum` command and includes a module-based `/greet` command. +This snippet showcases a bot with a minimal API-style `/pow` command and includes a module-based `/greet` command.
Required usings omitted for readability, click here to show @@ -52,7 +52,7 @@ 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 `/sum` command, which calculates the sum of two numbers: +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) @@ -60,7 +60,7 @@ var builder = Host.CreateDefaultBuilder(args) .UseApplicationCommands(); var host = builder.Build() - .AddSlashCommand("sum", "Sum", (int a, int b) => $"{a} + {b} = {a + b}") + .AddSlashCommand("square", "Square!", (int a) => $"{a}² = {a * a}") .UseGatewayEventHandlers(); await host.RunAsync(); From 25e81fff4d6fe97fef1474461dbc8d05d4f42b86 Mon Sep 17 00:00:00 2001 From: Kuba_Z2 <77853483+KubaZ2@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:42:20 +0200 Subject: [PATCH 7/7] Fix name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc6dc101b..7dba539e4 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ You can install NetCord packages via NuGet package manager: ## 2. 🚀 Showcase -This snippet showcases a bot with a minimal API-style `/pow` command and includes a module-based `/greet` command. +This snippet showcases a bot with a minimal API-style `/square` command and includes a module-based `/greet` command.
Required usings omitted for readability, click here to show