Class CommandRequirementAttribute
Represents any special validation that message needs to pass for command to be executed.
Namespace: TehGM.Wolfringo.Commands.Attributes
Assembly: Wolfringo.Commands.dll
Syntax
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public abstract class CommandRequirementAttribute : Attribute, ICommandRequirement
Properties
| Improve this Doc View SourceAbortOnFail
Whether check fail should cause Command execution to be aborted completely. True by default.
Declaration
public bool AbortOnFail { get; set; }
Property Value
Type | Description |
---|---|
System. |
ErrorMessage
The message that bot should reply with if requirement was not fulfilled.
Declaration
public string ErrorMessage { get; set; }
Property Value
Type | Description |
---|---|
System. |
FailureResult
Standard failure result.
Declaration
protected ICommandResult FailureResult { get; }
Property Value
Type | Description |
---|---|
ICommand |
Remarks
This result will automatically use Error
SendMessageWhenSkipping
Whether skip result should cause Error
Declaration
public bool SendMessageWhenSkipping { get; set; }
Property Value
Type | Description |
---|---|
System. |
Remarks
Has no effect if Abort
SuccessResult
Standard success result.
Declaration
protected ICommandResult SuccessResult { get; }
Property Value
Type | Description |
---|---|
ICommand |
Methods
| Improve this Doc View SourceCheckAsync(ICommandContext, IServiceProvider, CancellationToken)
Checks requirement.
Declaration
public abstract Task<ICommandResult> CheckAsync(ICommandContext context, IServiceProvider services, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
ICommand |
context | Command to check the requirement for. |
System. |
services | Services that can be used during requirement checks. |
System. |
cancellationToken | Token for cancelling the task. |
Returns
Type | Description |
---|---|
System. |
True if requirement was fullfilled; otherwise false. |
ResultFromBoolean(Boolean)
Converts a simple boolean to a proper command result.
Declaration
protected ICommandResult ResultFromBoolean(bool isSuccess)
Parameters
Type | Name | Description |
---|---|---|
System. |
isSuccess | Whether success or failure result should be returned. |
Returns
Type | Description |
---|---|
ICommand |
Command result based on |