Table of Contents

Struct AutocompletionResult

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

Contains the information of a Autocomplete Interaction result.

public struct AutocompletionResult : 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.

IsSuccess

Indicates whether the operation was successful or not.

public bool IsSuccess { get; }

Property Value

bool

true if the result is positive; otherwise false.

Suggestions

Get the collection of Autocomplete suggestions to be displayed to the user.

public readonly IReadOnlyCollection<AutocompleteResult> Suggestions { get; }

Property Value

IReadOnlyCollection<AutocompleteResult>

Methods

FromError(IResult)

Initializes a new AutocompletionResult with a specified result; this may or may not be an successful execution depending on the Error and ErrorReason specified.

public static AutocompletionResult FromError(IResult result)

Parameters

result IResult

The result to inherit from.

Returns

AutocompletionResult

A AutocompletionResult that inherits the IResult error type and reason.

FromError(InteractionCommandError, string)

Initializes a new AutocompletionResult with a specified InteractionCommandError and its reason, indicating an unsuccessful execution.

public static AutocompletionResult FromError(InteractionCommandError error, string reason)

Parameters

error InteractionCommandError

The type of error.

reason string

The reason behind the error.

Returns

AutocompletionResult

A AutocompletionResult that contains a InteractionCommandError and reason.

FromError(Exception)

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

public static AutocompletionResult FromError(Exception exception)

Parameters

exception Exception

The exception that caused the autocomplete process to fail.

Returns

AutocompletionResult

A AutocompletionResult 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 AutocompletionResult with no error and without any AutocompleteResult indicating the command service shouldn't return any suggestions.

public static AutocompletionResult FromSuccess()

Returns

AutocompletionResult

A AutocompletionResult that does not contain any errors.

FromSuccess(IEnumerable<AutocompleteResult>)

Initializes a new AutocompletionResult with no error.

public static AutocompletionResult FromSuccess(IEnumerable<AutocompleteResult> suggestions)

Parameters

suggestions IEnumerable<AutocompleteResult>

Autocomplete suggestions to be displayed to the user

Returns

AutocompletionResult

A AutocompletionResult that does not contain any errors.

ToString()

Gets a string that indicates the autocompletion result.

public override string ToString()

Returns

string

Success if IsSuccess is true; otherwise "Error: ErrorReason".