diff --git a/src/Discord.Net.Interactions/Results/SearchResult.cs b/src/Discord.Net.Interactions/Results/SearchResult.cs index 874e57d45..8555e9e5d 100644 --- a/src/Discord.Net.Interactions/Results/SearchResult.cs +++ b/src/Discord.Net.Interactions/Results/SearchResult.cs @@ -2,15 +2,34 @@ using System; namespace Discord.Interactions { - internal struct SearchResult : IResult where T : class, ICommandInfo + /// + /// Contains information of a command search. + /// + /// Type of the target command type. + public struct SearchResult : IResult where T : class, ICommandInfo { + /// + /// Gets the input text of the command search. + /// public string Text { get; } + + /// + /// Gets the found command, if the search was successful. + /// public T Command { get; } + + /// + /// Gets the Regex groups captured by the wild card pattern. + /// public string[] RegexCaptureGroups { get; } + + /// public InteractionCommandError? Error { get; } + /// public string ErrorReason { get; } + /// public bool IsSuccess => !Error.HasValue; private SearchResult (string text, T commandInfo, string[] captureGroups, InteractionCommandError? error, string reason) @@ -22,16 +41,53 @@ namespace Discord.Interactions ErrorReason = reason; } + /// + /// Initializes a new with no error, indicating a successful execution. + /// + /// + /// A that does not contain any errors. + /// public static SearchResult FromSuccess (string text, T commandInfo, string[] wildCardMatch = null) => new SearchResult(text, commandInfo, wildCardMatch, null, null); + /// + /// Initializes a new with a specified and its + /// reason, indicating an unsuccessful execution. + /// + /// The type of error. + /// The reason behind the error. + /// + /// A that contains a and reason. + /// public static SearchResult FromError (string text, InteractionCommandError error, string reason) => new SearchResult(text, null, null, error, reason); + + /// + /// Initializes a new with a specified exception, indicating an unsuccessful + /// execution. + /// + /// The exception that caused the command execution to fail. + /// + /// A that contains the exception that caused the unsuccessful execution, along + /// with a of type Exception as well as the exception message as the + /// reason. + /// public static SearchResult FromError (Exception ex) => new SearchResult(null, null, null, InteractionCommandError.Exception, ex.Message); + + /// + /// Initializes a new with a specified result; this may or may not be an + /// successful depending on the and + /// specified. + /// + /// The result to inherit from. + /// + /// A that inherits the error type and reason. + /// public static SearchResult FromError (IResult result) => new SearchResult(null, null, null, result.Error, result.ErrorReason); + /// public override string ToString ( ) => IsSuccess ? "Success" : $"{Error}: {ErrorReason}"; } }