Struct ExecuteResult
- Namespace
- Discord.Interactions
- Assembly
- Discord.Net.Interactions.dll
Contains information of the command's overall execution result.
public struct ExecuteResult : IResult
- Implements
- Inherited Members
Properties
Error
Gets the error type that may have occurred during the operation.
public readonly 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 readonly string ErrorReason { get; }
Property Value
- string
A string containing the error reason.
Exception
Gets the exception that may have occurred during the command execution.
public readonly Exception Exception { get; }
Property Value
IsSuccess
Indicates whether the operation was successful or not.
public bool IsSuccess { get; }
Property Value
Methods
FromError(IResult)
Initializes a new ExecuteResult with a specified result; this may or may not be an successful execution depending on the Error and ErrorReason specified.
public static ExecuteResult FromError(IResult result)
Parameters
result
IResultThe result to inherit from.
Returns
- ExecuteResult
A ExecuteResult that inherits the IResult error type and reason.
FromError(InteractionCommandError, string)
Initializes a new ExecuteResult with a specified InteractionCommandError and its reason, indicating an unsuccessful execution.
public static ExecuteResult FromError(InteractionCommandError commandError, string reason)
Parameters
commandError
InteractionCommandErrorThe type of error.
reason
stringThe reason behind the error.
Returns
- ExecuteResult
A ExecuteResult that contains a InteractionCommandError and reason.
FromError(Exception)
Initializes a new ExecuteResult with a specified exception, indicating an unsuccessful execution.
public static ExecuteResult FromError(Exception exception)
Parameters
exception
ExceptionThe exception that caused the command execution to fail.
Returns
- ExecuteResult
A ExecuteResult that contains the exception that caused the unsuccessful execution, along with a InteractionCommandError of type
Exception
as well as the exception message as the reason.
FromSuccess()
Initializes a new ExecuteResult with no error, indicating a successful execution.
public static ExecuteResult FromSuccess()
Returns
- ExecuteResult
A ExecuteResult that does not contain any errors.
ToString()
Gets a string that indicates the execution result.
public override string ToString()
Returns
- string
Success
if IsSuccess is true; otherwise "Error: ErrorReason".