forked from TeamInklings/Octobot
Merge some sequential 'if' statements (#284)
i thought there would be a lot of statements that could be merged, but these are only ones I could find, apparently Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
a80debf1b1
commit
e0232f6008
2 changed files with 7 additions and 23 deletions
|
@ -74,12 +74,8 @@ public class GuildLoadedResponder : IResponder<IGuildCreate>
|
|||
_logger.LogInformation("Loaded guild \"{Name}\" ({ID}) owned by {Owner} ({OwnerID}) with {MemberCount} members",
|
||||
guild.Name, guild.ID, owner.GetTag(), owner.ID, guild.MemberCount);
|
||||
|
||||
if (!GuildSettings.ReceiveStartupMessages.Get(cfg))
|
||||
{
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
if (GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty())
|
||||
if (GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty()
|
||||
|| !GuildSettings.ReceiveStartupMessages.Get(cfg))
|
||||
{
|
||||
return Result.Success;
|
||||
}
|
||||
|
|
|
@ -46,28 +46,16 @@ public class MessageEditedResponder : IResponder<IMessageUpdate>
|
|||
return new ArgumentNullError(nameof(gatewayEvent.ChannelID));
|
||||
}
|
||||
|
||||
if (!gatewayEvent.GuildID.IsDefined(out var guildId))
|
||||
{
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
if (gatewayEvent.Author.IsDefined(out var author) && author.IsBot.OrDefault(false))
|
||||
{
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
if (!gatewayEvent.EditedTimestamp.IsDefined(out var timestamp))
|
||||
{
|
||||
return Result.Success; // The message wasn't actually edited
|
||||
}
|
||||
|
||||
if (!gatewayEvent.Content.IsDefined(out var newContent))
|
||||
if (!gatewayEvent.GuildID.IsDefined(out var guildId)
|
||||
|| !gatewayEvent.Author.IsDefined(out var author)
|
||||
|| !gatewayEvent.EditedTimestamp.IsDefined(out var timestamp)
|
||||
|| !gatewayEvent.Content.IsDefined(out var newContent))
|
||||
{
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
var cfg = await _guildData.GetSettings(guildId, ct);
|
||||
if (GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty())
|
||||
if (author.IsBot.OrDefault(false) || GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty())
|
||||
{
|
||||
return Result.Success;
|
||||
}
|
||||
|
|
Reference in a new issue