From 5bd33e066b7a555ab33949fe0ba1b9dc597aa1f9 Mon Sep 17 00:00:00 2001 From: Pythonic-Rainbow Date: Sat, 23 Mar 2024 11:23:27 +0000 Subject: [PATCH] [Bot] Fix trying to delete main when alt leaves --- Bot/Clash/Coc.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Bot/Clash/Coc.cs b/Bot/Clash/Coc.cs index e97cafa..c9bd0c8 100644 --- a/Bot/Clash/Coc.cs +++ b/Bot/Clash/Coc.cs @@ -62,10 +62,9 @@ private static void CheckMembersLeft(ClanUtil clan) foreach ((string id, ClanMember member) in clan._leavingMembers) { - IEnumerable alts = new Member(id).GetAltsByMain(); + Member fakeMem = new(id); + IEnumerable alts = fakeMem.GetAltsByMain(); string? altId = null; - Main main = Db.GetMain(id)!; - main.Delete(); if (alts.Any()) { Alt alt = alts.First(); @@ -76,6 +75,8 @@ private static void CheckMembersLeft(ClanUtil clan) } alt.Delete(); // Maybe adapt this in the future if need to modify attributes when replacing main + Main main = fakeMem.ToMain(); + main.Delete(); main.MainId = altId; main.Insert(); }