Browse Source

[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
tags/3.6.0
Misha133 GitHub 3 years ago
parent
commit
18f001e37b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions
  1. +2
    -0
      docs/guides/int_framework/intro.md
  2. +21
    -0
      docs/guides/int_framework/samples/intro/groupmodule.cs

+ 2
- 0
docs/guides/int_framework/intro.md View File

@@ -282,6 +282,8 @@ By nesting commands inside a module that is tagged with [GroupAttribute] you can
> Although creating nested module stuctures are allowed, > Although creating nested module stuctures are allowed,
> you are not permitted to use more than 2 [GroupAttribute]'s in module hierarchy. > 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 ## Executing Commands


Any of the following socket events can be used to execute commands: Any of the following socket events can be used to execute commands:


+ 21
- 0
docs/guides/int_framework/samples/intro/groupmodule.cs View File

@@ -0,0 +1,21 @@
// You can put commands in groups
[Group("group-name", "Group description")]
public class CommandGroupModule : InteractionModuleBase<SocketInteractionContext>
{
// 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<SocketInteractionContext>
{
// 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);
}
}

Loading…
Cancel
Save