1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-05-05 21:46:28 +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)
{
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))
{
return Result.FromSuccess();
}
var cfg = await _guildData.GetSettings(guildId, ct);
if (GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty())
{
return Result.FromSuccess();
}
if (!gatewayEvent.Content.IsDefined(out var newContent))
if (gatewayEvent.Author.IsDefined(out var author) && author.IsBot.OrDefault(false))
{
return Result.FromSuccess();
}
@ -57,17 +61,13 @@ public class MessageEditedResponder : IResponder<IMessageUpdate>
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))
{
return new ArgumentNullError(nameof(gatewayEvent.ID));
}
if (gatewayEvent.Author.IsDefined(out var author) && author.IsBot.OrDefault(false))
var cfg = await _guildData.GetSettings(guildId, ct);
if (GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty())
{
return Result.FromSuccess();
}