-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
143 additions
and
100 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
Documentation/guides/services/application-commands/Introduction/ExampleModule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using NetCord; | ||
using NetCord.Rest; | ||
using NetCord.Services.ApplicationCommands; | ||
|
||
namespace MyBot; | ||
|
||
public class ExampleModule : ApplicationCommandModule<ApplicationCommandContext> | ||
{ | ||
[SlashCommand("pong", "Pong!")] | ||
public static string Pong() => "Ping!"; | ||
|
||
[UserCommand("ID")] | ||
public static string Id(User user) => user.Id.ToString(); | ||
|
||
[MessageCommand("Timestamp")] | ||
public static string Timestamp(RestMessage message) => message.CreatedAt.ToString(); | ||
} |
9 changes: 0 additions & 9 deletions
9
Documentation/guides/services/application-commands/Introduction/MessageCommandModule.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
Documentation/guides/services/application-commands/Introduction/SlashCommandModule.cs
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
Documentation/guides/services/application-commands/Introduction/UserCommandModule.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 24 additions & 12 deletions
36
Documentation/guides/services/application-commands/parameters.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,47 @@ | ||
# Parameters | ||
|
||
> [!WARNING] | ||
> Parameters are supported only by slash commands. | ||
## Slash Commands | ||
|
||
Slash commands support up to 25 parameters. | ||
|
||
### Optional parameters | ||
|
||
## Optional parameters | ||
To mark parameters as optional, give them a default value, example: | ||
[!code-cs[ExampleModule.cs](Parameters/ExampleModule.cs#L8-L13)] | ||
|
||
## Parameter name and description | ||
|
||
> [!IMPORTANT] | ||
> Parameter names **must** be lowercase. | ||
### Parameter name and description | ||
|
||
You can change parameter name and parameter description using @NetCord.Services.ApplicationCommands.SlashCommandParameterAttribute, example: | ||
[!code-cs[ExampleModule.cs](Parameters/ExampleModule.cs#L15-L21)] | ||
|
||
## Min and Max Values | ||
### Min and Max Values | ||
|
||
You can specify min and max parameter values by setting @NetCord.Services.ApplicationCommands.SlashCommandParameterAttribute.MinValue and @NetCord.Services.ApplicationCommands.SlashCommandParameterAttribute.MaxValue properties in @NetCord.Services.ApplicationCommands.SlashCommandParameterAttribute. It's only possible for numeric types. | ||
|
||
## Min and Max Length | ||
### Min and Max Length | ||
|
||
You can specify min and max parameter length by setting @NetCord.Services.ApplicationCommands.SlashCommandParameterAttribute.MinLength and @NetCord.Services.ApplicationCommands.SlashCommandParameterAttribute.MaxLength properties in @NetCord.Services.ApplicationCommands.SlashCommandParameterAttribute. It's only possible for text types. | ||
|
||
## Choices and Autocomplete | ||
### Choices and Autocomplete | ||
|
||
Choices are constants for a given parameter, autocomplete may depend on a text entered by a user. | ||
|
||
### Choices | ||
#### Choices | ||
|
||
Choices are automatically generated when you set `enum` as a parameter type, you can override choices' names using @NetCord.Services.ApplicationCommands.SlashCommandChoiceAttribute on enum fields, example: | ||
[!code-cs[ExampleModule.cs](Parameters/ExampleModule.cs#L23-L24)] | ||
[!code-cs[Animal.cs](Parameters/Animal.cs#l5-L12)] | ||
|
||
You can also define own choices in the Type Reader by overriding @NetCord.Services.ApplicationCommands.SlashCommandTypeReader`1.ChoicesProvider property or in @NetCord.Services.ApplicationCommands.SlashCommandParameterAttribute by setting @NetCord.Services.ApplicationCommands.SlashCommandParameterAttribute.ChoicesProviderType property. | ||
|
||
### Autocomplete | ||
#### Autocomplete | ||
|
||
You can turn on autocomplete in Type Reader by overriding @NetCord.Services.ApplicationCommands.SlashCommandTypeReader`1.AutocompleteProviderType property or in @NetCord.Services.ApplicationCommands.SlashCommandParameterAttribute by setting @NetCord.Services.ApplicationCommands.SlashCommandParameterAttribute.AutocompleteProviderType property. You run it using @NetCord.Services.ApplicationCommands.ApplicationCommandService`2.ExecuteAutocompleteAsync(`1,System.IServiceProvider). | ||
|
||
## User Commands | ||
|
||
User commands only support a single parameter of type @NetCord.User. It's is not required, but allows you to access the target user of the user command easily. | ||
|
||
## Message Commands | ||
|
||
Message commands only support a single parameter of type @NetCord.Rest.RestMessage. It's is not required, but allows you to access the target message of the message command easily. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.