From 18f001e37b5bbdd37b51f933b3b9c89d38c0c400 Mon Sep 17 00:00:00 2001 From: Misha133 <61027276+Misha-133@users.noreply.github.com> Date: Fri, 22 Apr 2022 13:26:54 +0300 Subject: [PATCH] [DOCS] Group commands example (#2246) * add Group Command Examples to int_framework intro * update subcommad group's name * added some comments t othe example code * fixed naming * added spaces in comments --- docs/guides/int_framework/intro.md | 2 ++ .../samples/intro/groupmodule.cs | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 docs/guides/int_framework/samples/intro/groupmodule.cs diff --git a/docs/guides/int_framework/intro.md b/docs/guides/int_framework/intro.md index abea2a735..f9eca370a 100644 --- a/docs/guides/int_framework/intro.md +++ b/docs/guides/int_framework/intro.md @@ -282,6 +282,8 @@ By nesting commands inside a module that is tagged with [GroupAttribute] you can > Although creating nested module stuctures are allowed, > you are not permitted to use more than 2 [GroupAttribute]'s in module hierarchy. +[!code-csharp[Command Group Example](samples/intro/groupmodule.cs)] + ## Executing Commands Any of the following socket events can be used to execute commands: diff --git a/docs/guides/int_framework/samples/intro/groupmodule.cs b/docs/guides/int_framework/samples/intro/groupmodule.cs new file mode 100644 index 000000000..f0d992aff --- /dev/null +++ b/docs/guides/int_framework/samples/intro/groupmodule.cs @@ -0,0 +1,21 @@ +// You can put commands in groups +[Group("group-name", "Group description")] +public class CommandGroupModule : InteractionModuleBase +{ + // This command will look like + // group-name ping + [SlashCommand("ping", "Get a pong")] + public async Task PongSubcommand() + => await RespondAsync("Pong!"); + + // And even in sub-command groups + [Group("subcommand-group-name", "Subcommand group description")] + public class SubСommandGroupModule : InteractionModuleBase + { + // This command will look like + // group-name subcommand-group-name echo + [SlashCommand("echo", "Echo an input")] + public async Task EchoSubcommand(string input) + => await RespondAsync(input); + } +} \ No newline at end of file