Esempio n. 1
0
 public ImpeachmentProceeding(CasinoMember target, CasinoMember from, string reason)
 {
     Target           = target;
     Reason           = reason;
     Initiator        = from;
     CouncilApprovals = new List <CasinoMember>()
     {
         from
     };
     MemberApprovals = new List <CasinoMember>()
     {
         from
     };
     RemovingFrom = new List <Division>();
 }
Esempio n. 2
0
        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");
                }
            }
        }