/// This method will ensure that the command is executable, execute all context checks, and then execute the command, and invoke the appropriate events.
/// </summary>
/// <remarks>
/// If any exceptions caused by the command were to occur, they will be delegated to the <see cref="CommandsExtension.CommandErrored"/> event.
/// </remarks>
/// <param name="context">The context of the command being executed.</param>
/// <param name="cancellationToken">The cancellation token to cancel the command execution.</param>
// it failed, add it to the list and continue with the others
if(resultis not null)
{
failedChecks.Add(new()
{
ParameterCheckAttribute=checkAttribute,
ErrorMessage=result
});
continue;
}
}
// if an error occurred, add it to the list and continue, making sure to set the error message.
catch(Exceptionerror)
{
failedChecks.Add(new()
{
ParameterCheckAttribute=checkAttribute,
ErrorMessage=error.Message,
Exception=error
});
}
}
}
}
returnfailedChecks;
}
/// <summary>
/// This method will execute the command provided without any safety checks, context checks or event invocation.
/// </summary>
/// <param name="context">The context of the command being executed.</param>
/// <returns>A tuple containing the command object and any error that occurred during execution. The command object may be null when the delegate is static and is from a static class.</returns>