Browse Source

Mention parameter precondition attribute

pull/826/head
Hsu Still 8 years ago
parent
commit
4449a05cdf
1 changed files with 11 additions and 5 deletions
  1. +11
    -5
      docs/guides/commands/commands.md

+ 11
- 5
docs/guides/commands/commands.md View File

@@ -246,11 +246,16 @@ mind, however, that they are not limited to _just_ permissions and can
be as complex as you want them to be. be as complex as you want them to be.


>[!NOTE] >[!NOTE]
>Preconditions can be applied to Modules, Groups, or Commands.
>There are two types of Preconditions.
[PreconditionAttribute] can be applied to Modules, Groups, or Commands;
[ParameterPreconditionAttribute] can be applied to Parameters.

[PreconditionAttribute]: xref:Discord.Commands.PreconditionAttribute
[ParameterPreconditionAttribute]: xref:Discord.Commands.ParameterPreconditionAttribute


## Bundled Preconditions ## Bundled Preconditions


Commands ship with four bundled preconditions; you may view their
Commands ship with four bundled Preconditions; you may view their
usages on their respective API pages. usages on their respective API pages.


- @Discord.Commands.RequireContextAttribute - @Discord.Commands.RequireContextAttribute
@@ -260,10 +265,11 @@ usages on their respective API pages.


## Custom Preconditions ## Custom Preconditions


To write your own precondition, create a new class that inherits from
@Discord.Commands.PreconditionAttribute.
To write your own Precondition, create a new class that inherits from
either [PreconditionAttribute] or [ParameterPreconditionAttribute]
depending on your use.


In order for your precondition to function, you will need to override
In order for your Precondition to function, you will need to override
the [CheckPermissions] method. the [CheckPermissions] method.


Your IDE should provide an option to fill this in for you. Your IDE should provide an option to fill this in for you.


Loading…
Cancel
Save