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, 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 |
---|---|
Boolean |
ErrorMessage
The message that bot should reply with if requirement was not fulfilled.
Declaration
public string ErrorMessage { get; set; }
Property Value
Type | Description |
---|---|
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 |
---|---|
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. |
IServiceProvider | services | Services that can be used during requirement checks. |
CancellationToken | cancellationToken | Token for cancelling the task. |
Returns
Type | Description |
---|---|
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 |
---|---|---|
Boolean | isSuccess | Whether success or failure result should be returned. |
Returns
Type | Description |
---|---|
ICommandResult | Command result based on |