Class PreconditionResult
- Namespace
- Discord.Interactions
- Assembly
- Discord.Net.Interactions.dll
Represents a result type for command preconditions.
public class PreconditionResult : IResult
- Inheritance
-
PreconditionResult
- Implements
- Derived
- Inherited Members
Constructors
PreconditionResult(InteractionCommandError?, string)
Initializes a new PreconditionResult class with the command error type
and reason.
protected PreconditionResult(InteractionCommandError? error, string reason)
Parameters
errorInteractionCommandError?The type of failure.
reasonstringThe reason of failure.
Properties
Error
Gets the error type that may have occurred during the operation.
public InteractionCommandError? Error { get; }
Property Value
- InteractionCommandError?
A InteractionCommandError indicating the type of error that may have occurred during the operation; null if the operation was successful.
ErrorReason
Gets the reason for the error.
public string ErrorReason { get; }
Property Value
- string
A string containing the error reason.
IsSuccess
Indicates whether the operation was successful or not.
public bool IsSuccess { get; }
Property Value
Methods
FromError(IResult)
Returns a PreconditionResult with the specified result type.
public static PreconditionResult FromError(IResult result)
Parameters
resultIResultThe result of failure.
Returns
FromError(Exception)
Returns a PreconditionResult with Exception and the Message.
public static PreconditionResult FromError(Exception exception)
Parameters
exceptionExceptionThe exception that caused the precondition check to fail.
Returns
FromError(string)
Returns a PreconditionResult with UnmetPrecondition and the specified reason.
public static PreconditionResult FromError(string reason)
Parameters
reasonstringThe reason of failure.
Returns
FromSuccess()
Returns a PreconditionResult with no errors.
public static PreconditionResult FromSuccess()