Class CommandRequirementAttribute
Represents any special validation that message needs to pass for command to be executed.
Inheritance
Implements
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, ICommandRequirementProperties
| 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.Boolean | 
ErrorMessage
The message that bot should reply with if requirement was not fulfilled.
Declaration
public string ErrorMessage { get; set; }Property Value
| Type | Description | 
|---|---|
| System.String | 
FailureResult
Standard failure result.
Declaration
protected ICommandResult FailureResult { get; }Property Value
| Type | Description | 
|---|---|
| ICommandResult | 
Remarks
This result will automatically use ErrorMessage if it's set.
SendMessageWhenSkipping
Whether skip result should cause ErrorMessage to be sent. Defaults to false.
Declaration
public bool SendMessageWhenSkipping { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
Remarks
Has no effect if AbortOnFail is set to false;
SuccessResult
Standard success result.
Declaration
protected ICommandResult SuccessResult { get; }Property Value
| Type | Description | 
|---|---|
| ICommandResult | 
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 | 
|---|---|---|
| ICommandContext | context | Command to check the requirement for. | 
| System.IServiceProvider | services | Services that can be used during requirement checks. | 
| System.Threading.CancellationToken | cancellationToken | Token for cancelling the task. | 
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task<ICommandResult> | 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.Boolean | isSuccess | Whether success or failure result should be returned. | 
Returns
| Type | Description | 
|---|---|
| ICommandResult | Command result based on  | 
