Class PreconditionResult
Represents a result type for command preconditions.
Implements
Namespace: Discord.Interactions
Assembly: Discord.Net.Interactions.dll
Syntax
public class PreconditionResult : object, IResult
Constructors
| Improve this Doc View SourcePreconditionResult(Nullable<InteractionCommandError>, String)
Initializes a new PreconditionResult class with the command error
type
and reason.
Declaration
protected PreconditionResult(InteractionCommandError? error, string reason)
Parameters
Type | Name | Description |
---|---|---|
Nullable<InteractionCommandError> | error | The type of failure. |
String | reason | The reason of failure. |
Properties
| Improve this Doc View SourceError
Gets the error type that may have occurred during the operation.
Declaration
public InteractionCommandError? Error { get; }
Property Value
Type | Description |
---|---|
Nullable<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.
Declaration
public string ErrorReason { get; }
Property Value
Type | Description |
---|---|
String | A string containing the error reason. |
IsSuccess
Indicates whether the operation was successful or not.
Declaration
public bool IsSuccess { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the result is positive; otherwise false. |
Methods
| Improve this Doc View SourceFromError(IResult)
Returns a PreconditionResult with the specified result
type.
Declaration
public static PreconditionResult FromError(IResult result)
Parameters
Type | Name | Description |
---|---|---|
IResult | result | The result of failure. |
Returns
Type | Description |
---|---|
PreconditionResult |
FromError(Exception)
Returns a PreconditionResult with Exception and the
Declaration
public static PreconditionResult FromError(Exception exception)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | The exception that caused the precondition check to fail. |
Returns
Type | Description |
---|---|
PreconditionResult |
FromError(String)
Returns a PreconditionResult with UnmetPrecondition and the specified reason.
Declaration
public static PreconditionResult FromError(string reason)
Parameters
Type | Name | Description |
---|---|---|
String | reason | The reason of failure. |
Returns
Type | Description |
---|---|
PreconditionResult |
FromSuccess()
Returns a PreconditionResult with no errors.
Declaration
public static PreconditionResult FromSuccess()
Returns
Type | Description |
---|---|
PreconditionResult |