Class RequireGroupPrivilegeAttribute
Command requirement that checks if the user has correct group permissions.
Inheritance
Implements
Inherited Members
Namespace: TehGM.Wolfringo.Commands.Attributes
Assembly: Wolfringo.Commands.dll
Syntax
public class RequireGroupPrivilegeAttribute : CommandRequirementAttribute, ICommandRequirement
Remarks
Default ErrorMessage for this requirement is "(n) You don't have enough group privileges to execute this command.".
Constructors
| Improve this Doc View SourceRequireGroupPrivilegeAttribute(WolfGroupCapabilities)
Creates a new instance of command group privilege requirement.
Declaration
public RequireGroupPrivilegeAttribute(WolfGroupCapabilities privileges)
Parameters
Type | Name | Description |
---|---|---|
WolfGroupCapabilities | privileges | Flags of privileges that fulfill this requirement. |
Remarks
Only one of the privileges has to match. For example, Owner | Admin matches if user is either Owner or Admin.
See Also
Properties
| Improve this Doc View SourceIgnoreInPrivate
Whether this requirement should be ignored in private messages.
Declaration
public bool IgnoreInPrivate { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
If this is set to true, CheckAsync(ICommandContext, IServiceProvider, CancellationToken) will always return true for private messages.
This is useful if the command should work normally in PM, even if in group it requires permissions.
If this is set to false, CheckAsync(ICommandContext, IServiceProvider, CancellationToken) will always return false for private messages.
This will make command group-only.
Defaults to false.
Privileges
Flags of privileges that fulfill this requirement.
Declaration
public WolfGroupCapabilities Privileges { get; }
Property Value
Type | Description |
---|---|
WolfGroupCapabilities |
Remarks
Only one of the privileges has to match. For example, Owner | Admin matches if user is either Owner or Admin.
Methods
| Improve this Doc View SourceCheckAsync(ICommandContext, IServiceProvider, CancellationToken)
Checks requirement.
Declaration
public override async 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. |
Overrides
| Improve this Doc View SourceCheckPrivilegeAsync(ICommandContext, UInt32, WolfGroupCapabilities, CancellationToken)
Checks if user has a specified privilege.
Declaration
public static async Task<bool> CheckPrivilegeAsync(ICommandContext context, uint userID, WolfGroupCapabilities privileges, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
ICommandContext | context | Context of the command execution. |
UInt32 | userID | ID of the user. |
WolfGroupCapabilities | privileges | Required privileges flags. |
CancellationToken | cancellationToken | Cancellation token for cancelling the task. |
Returns
Type | Description |
---|---|
Task<Boolean> | True if user has at least one of specified privileges; otherwise false. |