Table of Contents

Struct ExecuteResult

Namespace
Discord.Commands
Assembly
Discord.Net.Commands.dll

Contains information of the command's overall execution result.

public struct ExecuteResult : IResult
Implements
Inherited Members

Properties

Error

Describes the error type that may have occurred during the operation.

public readonly CommandError? Error { get; }

Property Value

CommandError?

A CommandError indicating the type of error that may have occurred during the operation; null if the operation was successful.

ErrorReason

Describes 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

Exception

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(CommandError, string)

Initializes a new ExecuteResult with a specified CommandError and its reason, indicating an unsuccessful execution.

public static ExecuteResult FromError(CommandError error, string reason)

Parameters

error CommandError

The type of error.

reason string

The reason behind the error.

Returns

ExecuteResult

A ExecuteResult that contains a CommandError and reason.

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 IResult

The result to inherit from.

Returns

ExecuteResult

A ExecuteResult that inherits the IResult error type and reason.

FromError(Exception)

Initializes a new ExecuteResult with a specified exception, indicating an unsuccessful execution.

public static ExecuteResult FromError(Exception ex)

Parameters

ex Exception

The exception that caused the command execution to fail.

Returns

ExecuteResult

A ExecuteResult that contains the exception that caused the unsuccessful execution, along with a CommandError 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".