Table of Contents

Class ParameterPreconditionAttribute

Namespace
Discord.Interactions
Assembly
Discord.Net.Interactions.dll

Requires the parameter to pass the specified precondition before execution can begin.

[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = true, Inherited = true)]
public abstract class ParameterPreconditionAttribute : Attribute
Inheritance
ParameterPreconditionAttribute
Inherited Members

Properties

ErrorMessage

Gets the error message to be returned if execution context doesn't pass the precondition check.

public virtual string ErrorMessage { get; }

Property Value

string

Remarks

When overridden in a derived class, uses the supplied string as the error message if the precondition doesn't pass. Setting this for a class that doesn't override this property is a no-op.

Methods

CheckRequirementsAsync(IInteractionContext, IParameterInfo, object, IServiceProvider)

Checks whether the condition is met before execution of the command.

public abstract Task<PreconditionResult> CheckRequirementsAsync(IInteractionContext context, IParameterInfo parameterInfo, object value, IServiceProvider services)

Parameters

context IInteractionContext

The context of the command.

parameterInfo IParameterInfo

The parameter of the command being checked against.

value object

The raw value of the parameter.

services IServiceProvider

The service collection used for dependency injection.

Returns

Task<PreconditionResult>

See Also