You can not select more than 25 topicsTopics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.
Preconditions serve as a permissions system for your Commands. Keep in
mind, however, that they are not limited to just permissions and can
be as complex as you want them to be.
There are two types of Preconditions you can use:
PreconditionAttribute can be applied to Modules, Groups, or Commands.
ParameterPreconditionAttribute can be applied to Parameters.
You may visit their respective API documentation to find out more.
Bundled Preconditions
@Discord.Commands ships with several bundled Preconditions for you
to use.
When writing commands, you may want to allow some of them to be
executed when only some of the precondition checks are passed.
This is where the Group property of a precondition attribute comes in
handy. By assigning two or more preconditions to a group, the command
system will allow the command to be executed when one of the
precondition passes.
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
the CheckPermissionsAsync method.
If the context meets the required parameters, return
PreconditionResult.FromSuccess, otherwise return
PreconditionResult.FromError and include an error message if
necessary.
[!NOTE]
Visual Studio can help you implement missing members
from the abstract class by using the "Implement Abstract Class"
IntelliSense hint.
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.