Table of Contents

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

error InteractionCommandError?

The type of failure.

reason string

The 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

bool

true if the result is positive; otherwise false.

Methods

FromError(IResult)

Returns a PreconditionResult with the specified result type.

public static PreconditionResult FromError(IResult result)

Parameters

result IResult

The result of failure.

Returns

PreconditionResult

FromError(Exception)

Returns a PreconditionResult with Exception and the Message.

public static PreconditionResult FromError(Exception exception)

Parameters

exception Exception

The exception that caused the precondition check to fail.

Returns

PreconditionResult

FromError(string)

Returns a PreconditionResult with UnmetPrecondition and the specified reason.

public static PreconditionResult FromError(string reason)

Parameters

reason string

The reason of failure.

Returns

PreconditionResult

FromSuccess()

Returns a PreconditionResult with no errors.

public static PreconditionResult FromSuccess()

Returns

PreconditionResult