Using pattern matching for nulls where applicable, discarded unused lambda parameters, cleaned up some classes. Unignored ServerLog commands which was mistakenly ignored due to a .gitignore rule

This commit is contained in:
Kwoth
2022-01-01 08:44:51 +01:00
parent f81f9fadd3
commit 9b4eb21321
91 changed files with 1591 additions and 224 deletions

View File

@@ -80,7 +80,7 @@ public class UserPunishService : INService
var p = ps.FirstOrDefault(x => x.Count == warnings);
if (p != null)
if (p is not null)
{
var user = await guild.GetUserAsync(userId);
if (user is null)
@@ -305,9 +305,9 @@ WHERE GuildId={guildId}
IRole role = null)
{
// these 3 don't make sense with time
if (punish is PunishmentAction.Softban or PunishmentAction.Kick or PunishmentAction.RemoveRoles && time != null)
if (punish is PunishmentAction.Softban or PunishmentAction.Kick or PunishmentAction.RemoveRoles && time is not null)
return false;
if (number <= 0 || (time != null && time.Time > TimeSpan.FromDays(49)))
if (number <= 0 || (time is not null && time.Time > TimeSpan.FromDays(49)))
return false;
using var uow = _db.GetDbContext();
@@ -336,7 +336,7 @@ WHERE GuildId={guildId}
var ps = uow.GuildConfigsForId(guildId, set => set.Include(x => x.WarnPunishments)).WarnPunishments;
var p = ps.FirstOrDefault(x => x.Count == number);
if (p != null)
if (p is not null)
{
uow.Remove(p);
uow.SaveChanges();