mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-11 00:13:15 +03:00
Add a new .editorconfig and reformat code (#76)
*I'll start working on features and bugfixes after this PR, I promise* very short summary: - no more braceless statements - braces are on new lines now - `sealed` on everything that can be `sealed` - no more awkwardly looking alignment of fields/parameters - no more `Service` suffix on service fields. yeah. - no more `else`s. who needs them? - code style is now enforced by CI --------- Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
4cb39a34b5
commit
84e730838b
39 changed files with 2917 additions and 623 deletions
|
@ -11,10 +11,12 @@ namespace Boyfriend.Commands.Events;
|
|||
/// Handles error logging for slash command groups.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent {
|
||||
public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent
|
||||
{
|
||||
private readonly ILogger<ErrorLoggingPostExecutionEvent> _logger;
|
||||
|
||||
public ErrorLoggingPostExecutionEvent(ILogger<ErrorLoggingPostExecutionEvent> logger) {
|
||||
public ErrorLoggingPostExecutionEvent(ILogger<ErrorLoggingPostExecutionEvent> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
@ -27,11 +29,15 @@ public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent {
|
|||
/// <param name="ct">The cancellation token for this operation. Unused.</param>
|
||||
/// <returns>A result which has succeeded.</returns>
|
||||
public Task<Result> AfterExecutionAsync(
|
||||
ICommandContext context, IResult commandResult, CancellationToken ct = default) {
|
||||
if (!commandResult.IsSuccess && !commandResult.Error.IsUserOrEnvironmentError()) {
|
||||
ICommandContext context, IResult commandResult, CancellationToken ct = default)
|
||||
{
|
||||
if (!commandResult.IsSuccess && !commandResult.Error.IsUserOrEnvironmentError())
|
||||
{
|
||||
_logger.LogWarning("Error in slash command execution.\n{ErrorMessage}", commandResult.Error.Message);
|
||||
if (commandResult.Error is ExceptionError exerr)
|
||||
{
|
||||
_logger.LogError(exerr.Exception, "An exception has been thrown");
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult(Result.FromSuccess());
|
||||
|
|
|
@ -11,10 +11,12 @@ namespace Boyfriend.Commands.Events;
|
|||
/// Handles error logging for slash commands that couldn't be successfully prepared.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public class LoggingPreparationErrorEvent : IPreparationErrorEvent {
|
||||
public class LoggingPreparationErrorEvent : IPreparationErrorEvent
|
||||
{
|
||||
private readonly ILogger<LoggingPreparationErrorEvent> _logger;
|
||||
|
||||
public LoggingPreparationErrorEvent(ILogger<LoggingPreparationErrorEvent> logger) {
|
||||
public LoggingPreparationErrorEvent(ILogger<LoggingPreparationErrorEvent> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
@ -27,11 +29,15 @@ public class LoggingPreparationErrorEvent : IPreparationErrorEvent {
|
|||
/// <param name="ct">The cancellation token for this operation. Unused.</param>
|
||||
/// <returns>A result which has succeeded.</returns>
|
||||
public Task<Result> PreparationFailed(
|
||||
IOperationContext context, IResult preparationResult, CancellationToken ct = default) {
|
||||
if (!preparationResult.IsSuccess && !preparationResult.Error.IsUserOrEnvironmentError()) {
|
||||
IOperationContext context, IResult preparationResult, CancellationToken ct = default)
|
||||
{
|
||||
if (!preparationResult.IsSuccess && !preparationResult.Error.IsUserOrEnvironmentError())
|
||||
{
|
||||
_logger.LogWarning("Error in slash command preparation.\n{ErrorMessage}", preparationResult.Error.Message);
|
||||
if (preparationResult.Error is ExceptionError exerr)
|
||||
{
|
||||
_logger.LogError(exerr.Exception, "An exception has been thrown");
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult(Result.FromSuccess());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue