Skip to content

Commit

Permalink
[Bot] Fix trying to delete main when alt leaves
Browse files Browse the repository at this point in the history
  • Loading branch information
Pythonic-Rainbow committed Mar 23, 2024
1 parent b45324c commit 5bd33e0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Bot/Clash/Coc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ private static void CheckMembersLeft(ClanUtil clan)

foreach ((string id, ClanMember member) in clan._leavingMembers)
{
IEnumerable<Alt> alts = new Member(id).GetAltsByMain();
Member fakeMem = new(id);
IEnumerable<Alt> alts = fakeMem.GetAltsByMain();
string? altId = null;
Main main = Db.GetMain(id)!;
main.Delete();
if (alts.Any())
{
Alt alt = alts.First();
Expand All @@ -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();
}
Expand Down

0 comments on commit 5bd33e0

Please sign in to comment.