From 7ac94e907f3b1d50154d296f0d1b659c6b7c7116 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Tue, 16 May 2017 22:00:55 +0200 Subject: [PATCH] .warnp will now correctly overwrite old setting on the same number of warnings --- .../Commands/UserPunishCommands.cs | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/UserPunishCommands.cs b/src/NadekoBot/Modules/Administration/Commands/UserPunishCommands.cs index f794d47a..ad28d5ae 100644 --- a/src/NadekoBot/Modules/Administration/Commands/UserPunishCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/UserPunishCommands.cs @@ -214,25 +214,15 @@ namespace NadekoBot.Modules.Administration using (var uow = DbHandler.UnitOfWork()) { - var ps = uow.GuildConfigs.For(Context.Guild.Id).WarnPunishments; - var p = ps.FirstOrDefault(x => x.Count == number); + var ps = uow.GuildConfigs.For(Context.Guild.Id, set => set.Include(x => x.WarnPunishments)).WarnPunishments; + ps.RemoveAll(x => x.Count == number); - if (p == null) + ps.Add(new WarningPunishment() { - ps.Add(new WarningPunishment() - { - Count = number, - Punishment = punish, - Time = time, - }); - } - else - { - p.Count = number; - p.Punishment = punish; - p.Time = time; - uow._context.Update(p); - } + Count = number, + Punishment = punish, + Time = time, + }); uow.Complete(); }