1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-05-06 22:16:29 +03:00

refactor: reorder 'if' chain

This commit is contained in:
Octol1ttle 2023-12-17 21:58:03 +05:00
parent e427469de3
commit fc4cafd282
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF

View file

@ -36,18 +36,22 @@ public class MessageEditedResponder : IResponder<IMessageUpdate>
public async Task<Result> RespondAsync(IMessageUpdate gatewayEvent, CancellationToken ct = default) public async Task<Result> RespondAsync(IMessageUpdate gatewayEvent, CancellationToken ct = default)
{ {
if (!gatewayEvent.ID.IsDefined(out var messageId))
{
return new ArgumentNullError(nameof(gatewayEvent.ID));
}
if (!gatewayEvent.ChannelID.IsDefined(out var channelId))
{
return new ArgumentNullError(nameof(gatewayEvent.ChannelID));
}
if (!gatewayEvent.GuildID.IsDefined(out var guildId)) if (!gatewayEvent.GuildID.IsDefined(out var guildId))
{ {
return Result.FromSuccess(); return Result.FromSuccess();
} }
var cfg = await _guildData.GetSettings(guildId, ct); if (gatewayEvent.Author.IsDefined(out var author) && author.IsBot.OrDefault(false))
if (GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty())
{
return Result.FromSuccess();
}
if (!gatewayEvent.Content.IsDefined(out var newContent))
{ {
return Result.FromSuccess(); return Result.FromSuccess();
} }
@ -57,17 +61,13 @@ public class MessageEditedResponder : IResponder<IMessageUpdate>
return Result.FromSuccess(); // The message wasn't actually edited return Result.FromSuccess(); // The message wasn't actually edited
} }
if (!gatewayEvent.ChannelID.IsDefined(out var channelId)) if (!gatewayEvent.Content.IsDefined(out var newContent))
{ {
return new ArgumentNullError(nameof(gatewayEvent.ChannelID)); return Result.FromSuccess();
} }
if (!gatewayEvent.ID.IsDefined(out var messageId)) var cfg = await _guildData.GetSettings(guildId, ct);
{ if (GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty())
return new ArgumentNullError(nameof(gatewayEvent.ID));
}
if (gatewayEvent.Author.IsDefined(out var author) && author.IsBot.OrDefault(false))
{ {
return Result.FromSuccess(); return Result.FromSuccess();
} }