Table of Contents

Struct SearchResult<T>

Namespace
Discord.Interactions
Assembly
Discord.Net.Interactions.dll

Contains information of a command search.

public struct SearchResult<T> : IResult where T : class, ICommandInfo

Type Parameters

T

Type of the target command type.

Implements
Inherited Members

Properties

Command

Gets the found command, if the search was successful.

public readonly T Command { get; }

Property Value

T

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.

IsSuccess

Indicates whether the operation was successful or not.

public bool IsSuccess { get; }

Property Value

bool

true if the result is positive; otherwise false.

RegexCaptureGroups

Gets the Regex groups captured by the wild card pattern.

public readonly string[] RegexCaptureGroups { get; }

Property Value

string[]

Text

Gets the input text of the command search.

public readonly string Text { get; }

Property Value

string

Methods

FromError(IResult)

Initializes a new SearchResult<T> with a specified result; this may or may not be an successful depending on the Error and ErrorReason specified.

public static SearchResult<T> FromError(IResult result)

Parameters

result IResult

The result to inherit from.

Returns

SearchResult<T>

A SearchResult<T> that inherits the IResult error type and reason.

FromError(Exception)

Initializes a new SearchResult<T> with a specified exception, indicating an unsuccessful execution.

public static SearchResult<T> FromError(Exception ex)

Parameters

ex Exception

The exception that caused the command execution to fail.

Returns

SearchResult<T>

A SearchResult<T> 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.

FromError(string, InteractionCommandError, string)

Initializes a new SearchResult<T> with a specified InteractionCommandError and its reason, indicating an unsuccessful execution.

public static SearchResult<T> FromError(string text, InteractionCommandError error, string reason)

Parameters

text string
error InteractionCommandError

The type of error.

reason string

The reason behind the error.

Returns

SearchResult<T>

A SearchResult<T> that contains a InteractionCommandError and reason.

FromSuccess(string, T, string[])

Initializes a new SearchResult<T> with no error, indicating a successful execution.

public static SearchResult<T> FromSuccess(string text, T commandInfo, string[] wildCardMatch = null)

Parameters

text string
commandInfo T
wildCardMatch string[]

Returns

SearchResult<T>

A SearchResult<T> that does not contain any errors.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.