Use Result.Success property instead of Result.FromSuccess() (#283)

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2024-03-21 20:55:34 +05:00 committed by GitHub
parent 309d900067
commit a80debf1b1
Signed by: GitHub
GPG key ID: B5690EEEBB952194
18 changed files with 59 additions and 54 deletions

View file

@ -20,8 +20,8 @@ namespace Octobot.Commands.Events;
[UsedImplicitly]
public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent
{
private readonly ILogger<ErrorLoggingPostExecutionEvent> _logger;
private readonly IFeedbackService _feedback;
private readonly ILogger<ErrorLoggingPostExecutionEvent> _logger;
private readonly IDiscordRestUserAPI _userApi;
public ErrorLoggingPostExecutionEvent(ILogger<ErrorLoggingPostExecutionEvent> logger, IFeedbackService feedback,
@ -53,7 +53,7 @@ public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent
if (result.IsSuccess)
{
return Result.FromSuccess();
return Result.Success;
}
var botResult = await _userApi.GetCurrentUserAsync(ct);

View file

@ -33,6 +33,6 @@ public class LoggingPreparationErrorEvent : IPreparationErrorEvent
{
_logger.LogResult(preparationResult, "Error in slash command preparation.");
return Task.FromResult(Result.FromSuccess());
return Task.FromResult(Result.Success);
}
}

View file

@ -118,7 +118,8 @@ public class MuteCommandGroup : CommandGroup
return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: CancellationToken);
}
return await MuteUserAsync(executor, target, reason, duration, guildId, data, channelId, bot, CancellationToken);
return await MuteUserAsync(executor, target, reason, duration, guildId, data, channelId, bot,
CancellationToken);
}
private async Task<Result> MuteUserAsync(
@ -143,14 +144,16 @@ public class MuteCommandGroup : CommandGroup
var until = DateTimeOffset.UtcNow.Add(duration); // >:)
var muteMethodResult = await SelectMuteMethodAsync(executor, target, reason, duration, guildId, data, bot, until, ct);
var muteMethodResult =
await SelectMuteMethodAsync(executor, target, reason, duration, guildId, data, bot, until, ct);
if (!muteMethodResult.IsSuccess)
{
return ResultExtensions.FromError(muteMethodResult);
}
var title = string.Format(Messages.UserMuted, target.GetTag());
var description = new StringBuilder().AppendBulletPointLine(string.Format(Messages.DescriptionActionReason, reason))
var description = new StringBuilder()
.AppendBulletPointLine(string.Format(Messages.DescriptionActionReason, reason))
.AppendBulletPoint(string.Format(
Messages.DescriptionActionExpiresAt, Markdown.Timestamp(until))).ToString();
@ -348,11 +351,12 @@ public class MuteCommandGroup : CommandGroup
}
private async Task<Result> RemoveMuteRoleAsync(
IUser executor, IUser target, string reason, Snowflake guildId, MemberData memberData, CancellationToken ct = default)
IUser executor, IUser target, string reason, Snowflake guildId, MemberData memberData,
CancellationToken ct = default)
{
if (memberData.MutedUntil is null)
{
return Result.FromSuccess();
return Result.Success;
}
var unmuteResult = await _guildApi.ModifyGuildMemberAsync(
@ -372,7 +376,7 @@ public class MuteCommandGroup : CommandGroup
{
if (communicationDisabledUntil is null)
{
return Result.FromSuccess();
return Result.Success;
}
var unmuteResult = await _guildApi.ModifyGuildMemberAsync(