public async Task CheckForEnd() { if (Impeachment != null) { if (Impeachment.TargetIndicted) { if (Impeachment.TargetRemoved) { await Impeachment.SentMessage.Channel.SendMessageAsync($"{Impeachment.Target.Name} has been impeached and removed!"); foreach (var div in Impeachment.RemovingFrom) { div.Employees.RemoveAll(x => x.Id == Impeachment.Target.User.Id); if (div.DivisionHead.Id == Impeachment.Target.User.Id) { if (div.Employees.Count > 0) { div.DivisionHead = div.Employees.FirstOrDefault(); await div.DivisionHead.AddRoleAsync(div.DivisionHeadRole); await div.DivisionStaffChannel.SendMessageAsync($"Division Head was impeached and {div.DivisionHead.Username} has been promoted"); } else { div.DivisionHead = FourAcesCasino.GetMember("Four Aces Casino").User; await div.DivisionStaffChannel.SendMessageAsync($"Division Head was impeached\r\nDivision currently has no employees at all."); } } else { await div.DivisionStaffChannel.SendMessageAsync($"{Impeachment.Target.Name} was impeached for {Impeachment.Reason}\r\nThey ***must not*** be re-hired"); } } await Program.C_LOGS_FAC_DIVISION.SendMessageAsync("Logging impeachment vote that passed successfully", false, Impeachment.ToEmbed()); Impeachment = null; FourAcesCasino.Save(); } } } }
public async Task StartProceedings(CasinoMember target, string reason) { if (Impeachment != null) { await ReplyAsync("Error: there is already a proceeding:", false, Impeachment.ToEmbed()); } else { var im = new ImpeachmentProceeding(target, SelfMember, reason); var divisions = FourAcesCasino.Divisions.Where(x => x.Employees.Contains(target.User)); if (divisions.Count() == 0) { await ReplyAsync("Error: that target is not employed at all"); return; } else if (divisions.Count() == 1) { im.RemovingFrom.Add(divisions.First()); } else { EmbedBuilder builder = new EmbedBuilder() { Title = "Multiple Options", Description = "Which Division is the person to be impeached from?\nPlease chose an option by giving the number" }; builder.AddField("0 - All Divisions", "From ***every*** Division"); int opt = 1; foreach (var d in divisions) { builder.AddField($"{opt++} - {d.Name}", d.DivisionHead.Id == target.User.Id ? "Division Head" : "Employee"); } await ReplyAsync("Please chose:", false, builder.Build()); var next = await NextMessageAsync(timeout : TimeSpan.FromMinutes(3)); if (next == null) { await ReplyAsync("Error: no reply at all"); return; } if (int.TryParse(next.Content, out int id)) { if (id == 0) { im.RemovingFrom.AddRange(divisions); } else { int count = 1; foreach (var d in divisions) { if (count == id) { im.RemovingFrom.Add(d); break; } count++; } } } else { await ReplyAsync("Error: could not parse as integer"); return; } } await ReplyAsync("Please reply with `confirm` to submit the following impeachment:", false, im.ToEmbed()); var confirm = await NextMessageAsync(timeout : TimeSpan.FromMinutes(2)); if (confirm != null && confirm.Content == "confirm") { Impeachment = im; ITextChannel channel = null; if (Program.BOT_DEBUG) { channel = Program.CasinoGuild.GetTextChannel(443073939028049921); } else { channel = Program.C_GENERAL; } var message = await channel.SendMessageAsync($"{Program.CasinoGuild.EveryoneRole.Mention} \r\nAn impeachment proceeding has now been brought" + $"\r\nAn impeachment should only take place for the most serious of offences of the Contract."); Impeachment.SentMessage = message; Impeachment.ToEmbed(); } else { await ReplyAsync("Impeachment canceled"); } } }