Precondition 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:
You may visit their respective API documentation to find out more.
@Discord.Commands ship with several bundled Preconditions; you may
view their usages on their respective API pages.
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.
Your IDE should provide an option to fill this in for you.
If the context meets the required parameters, return
PreconditionResult.FromSuccess, otherwise return
PreconditionResult.FromError and include an error message if
necessary.
[!code-csharpCustom Precondition]