Struct SearchResult<T>
Contains information of a command search.
Implements
Namespace: Discord.Interactions
Assembly: Discord.Net.Interactions.dll
Syntax
public struct SearchResult<T> : IResult where T : class, ICommandInfo
Type Parameters
Name | Description |
---|---|
T | Type of the target command type. |
Properties
| Improve this Doc View SourceCommand
Gets the found command, if the search was successful.
Declaration
public readonly T Command { get; }
Property Value
Type | Description |
---|---|
T |
Error
Gets the error type that may have occurred during the operation.
Declaration
public readonly 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 readonly 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 readonly bool IsSuccess { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the result is positive; otherwise false. |
RegexCaptureGroups
Gets the Regex groups captured by the wild card pattern.
Declaration
public readonly string[] RegexCaptureGroups { get; }
Property Value
Type | Description |
---|---|
String[] |
Text
Gets the input text of the command search.
Declaration
public readonly string Text { get; }
Property Value
Type | Description |
---|---|
String |
Methods
| Improve this Doc View SourceFromError(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.
Declaration
public static SearchResult<T> FromError(IResult result)
Parameters
Type | Name | Description |
---|---|---|
IResult | result | The result to inherit from. |
Returns
Type | Description |
---|---|
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.
Declaration
public static SearchResult<T> FromError(Exception ex)
Parameters
Type | Name | Description |
---|---|---|
Exception | ex | The exception that caused the command execution to fail. |
Returns
Type | Description |
---|---|
SearchResult<T> | A SearchResult<T> that contains the exception that caused the unsuccessful execution, along
with a InteractionCommandError of type |
FromError(String, InteractionCommandError, String)
Initializes a new SearchResult<T> with a specified InteractionCommandError and its reason, indicating an unsuccessful execution.
Declaration
public static SearchResult<T> FromError(string text, InteractionCommandError error, string reason)
Parameters
Type | Name | Description |
---|---|---|
String | text | |
InteractionCommandError | error | The type of error. |
String | reason | The reason behind the error. |
Returns
Type | Description |
---|---|
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.
Declaration
public static SearchResult<T> FromSuccess(string text, T commandInfo, string[] wildCardMatch = null)
Parameters
Type | Name | Description |
---|---|---|
String | text | |
T | commandInfo | |
String[] | wildCardMatch |
Returns
Type | Description |
---|---|
SearchResult<T> | A SearchResult<T> that does not contain any errors. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |