private async Task StrikeUser(SocketUser user)
        {
            // First, the classic null check
            if (BotUtils.GetGUser(Context) == null)
            {
                await Context.Channel.SendMessageAsync(BotUtils.KamtroText("That user does not exist!"));

                KLog.Info($"User {BotUtils.GetFullUsername(Context.User)} attempted to strike non-existant member {BotUtils.GetFullUsername(user)}");
                return;
            }

            // Flavor text for trying to strike yourself
            if (user.Id == Context.User.Id)
            {
                await Context.Channel.SendMessageAsync(BotUtils.KamtroText("We would like to save the strikes for those that deserve it."));

                return;
            }

            // next, check to see if Kamtro has perms to ban the user
            if (!BotUtils.HighestUser(BotUtils.GetGUser(Context.Client.CurrentUser.Id), BotUtils.GetGUser(user.Id)))
            {
                await Context.Channel.SendMessageAsync(BotUtils.KamtroText("The user is higher than me, so I cannot strike them."));

                KLog.Info($"User {BotUtils.GetFullUsername(Context.User)} attempted to strike member {BotUtils.GetFullUsername(user)} of higher status than bot");
                return;
            }

            // next, check if the caller can ban the user
            if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
            {
                if (BotUtils.HighestUser(BotUtils.GetGUser(user.Id), BotUtils.GetGUser(Context), true))
                {
                    await Context.Channel.SendMessageAsync(BotUtils.KamtroText("This user is higher or equal than you, and as such, you cannot strike them."));

                    KLog.Info($"User {BotUtils.GetFullUsername(Context.User)} attempted to strike member {BotUtils.GetFullUsername(user)} of higher status than caller");
                    return;
                }
            }

            if (AdminDataManager.GetStrikes(user) >= 2)
            {
                await BanUser(user);

                return;
            }

            StrikeEmbed se = new StrikeEmbed(Context, user);
            await se.Display();
        }
Exemple #2
0
        public override Embed GetEmbed()
        {
            EmbedBuilder eb = new EmbedBuilder();

            eb.WithTitle($"Ban {BotUtils.GetFullUsername(Target)}");
            eb.WithThumbnailUrl(Target.GetAvatarUrl());
            eb.WithColor(BotUtils.Red);

            eb.AddField("User Strike Count:", AdminDataManager.GetStrikes(Target).ToString());

            eb.AddField("Will notify user?", notifyTarget ? "Yes" : "No");

            AddEmbedFields(eb);
            AddMenu(eb);

            return(eb.Build());
        }
Exemple #3
0
        public override Embed GetEmbed()
        {
            EmbedBuilder eb = new EmbedBuilder();

            eb.WithTitle($"Add Strike for {BotUtils.GetFullUsername(Target)}");
            eb.WithThumbnailUrl(Target.GetAvatarUrl());
            eb.WithColor(BotUtils.Orange);

            eb.AddField("User's current strike count:", $"{AdminDataManager.GetStrikes(Target)}");

            eb.AddField("Will notify user?", notifyUser ? "Yes":"No");

            AddEmbedFields(eb);
            AddMenu(eb);

            return(eb.Build());
        }
        private void HandleConfirm()
        {
            LastPage = PageNum;

            switch (PageNum)
            {
            case 1:
                switch (OpCursor + 1)
                {
                case 1:
                    PageNum = 2;
                    break;

                case 2:
                    PageNum = 4;
                    break;

                case 3:
                    PageNum = 9;
                    break;
                }
                break;

            case 2:
                // autofill
                if (Autofill != null)
                {
                    InputFields[3][1].SetValue(Parse(Autofill.Id.ToString()));
                    InputFields[3][2].SetValue(Parse(BotUtils.GetFullUsername(Autofill)));
                    InputFields[3][3].SetValue(Parse(AdminDataManager.GetStrikeReason(Autofill.Id, 1)));
                    InputFields[3][4].SetValue(Parse(AdminDataManager.GetStrikeReason(Autofill.Id, 2)));
                    InputFields[3][5].SetValue(Parse(AdminDataManager.GetStrikeReason(Autofill.Id, 3)));
                }

                PageNum = 3;
                break;

            case 3:
                ulong id;
                if (!string.IsNullOrWhiteSpace(UserId) && ulong.TryParse(UserId, out id))
                {
                    bool strike1Added = false;
                    bool strike2Added = false;

                    if (!string.IsNullOrWhiteSpace(Strike1Reason) && Strike1Reason != DefaultText)
                    {
                        AdminDataManager.AddStrike(id, new StrikeDataNode(Context.User, Strike1Reason), BotUtils.GetFullUsername(BotUtils.GetGUser(id)), AdminDataManager.GetStrikes(id) >= 1);
                        strike1Added = true;
                    }

                    if (!string.IsNullOrWhiteSpace(Strike2Reason) && Strike2Reason != DefaultText)
                    {
                        if (!strike1Added && AdminDataManager.GetStrikes(id) == 0)
                        {
                            // Add strike 1 if it wasn't added a few lines ago, and it isn't already there
                            AdminDataManager.AddStrike(id, new StrikeDataNode(Context.User, Strike1Reason), BotUtils.GetFullUsername(BotUtils.GetGUser(id)), AdminDataManager.GetStrikes(id) >= 1);
                            strike1Added = true;
                        }

                        // Add strike 2
                        AdminDataManager.AddStrike(id, new StrikeDataNode(Context.User, Strike2Reason), BotUtils.GetFullUsername(BotUtils.GetGUser(id)), AdminDataManager.GetStrikes(id) >= 2);
                        strike2Added = true;
                    }

                    if (!string.IsNullOrWhiteSpace(BanReason) && BanReason != DefaultText)
                    {
                        if (!strike1Added && AdminDataManager.GetStrikes(id) == 0)
                        {
                            // Add strike 1 if it wasn't added a few lines ago, and it isn't already there
                            AdminDataManager.AddStrike(id, new StrikeDataNode(Context.User, Strike1Reason), BotUtils.GetFullUsername(BotUtils.GetGUser(id)), AdminDataManager.GetStrikes(id) >= 1);
                        }

                        if (!strike2Added && AdminDataManager.GetStrikes(id) == 1)
                        {
                            AdminDataManager.AddStrike(id, new StrikeDataNode(Context.User, Strike2Reason), BotUtils.GetFullUsername(BotUtils.GetGUser(id)), AdminDataManager.GetStrikes(id) >= 2);
                        }

                        AdminDataManager.AddBan(id, new BanDataNode(Context.User, BanReason), BotUtils.GetFullUsername(BotUtils.GetGUser(id)));
                    }

                    PageNum = 14;
                }
                break;

            case 4:
                // autofill
                if (Autofill != null)
                {
                    UserId       = Autofill.Id.ToString();
                    FullUsername = BotUtils.GetFullUsername(Autofill);
                    InputFields[6][1].SetValue(Parse(AdminDataManager.GetStrikeReason(Autofill.Id, 1)));
                    InputFields[7][1].SetValue(Parse(AdminDataManager.GetStrikeReason(Autofill.Id, 2)));
                    InputFields[8][1].SetValue(Parse(AdminDataManager.GetStrikeReason(Autofill.Id, 3)));
                }
                else
                {
                    return;     // you must specify a user
                }

                PageNum = 5;
                break;

            case 5:
                switch (OpCursor + 1)
                {
                case 1:
                    PageNum = 6;
                    break;

                case 2:
                    PageNum = 7;
                    break;

                case 3:
                    PageNum = 8;
                    break;
                }
                break;

            case 6:
                // handle confirm
                AdminDataManager.SetStrikeReason(Autofill.Id, 1, Strike1Reason6, BotUtils.GetGUser(Context));
                PageNum = 14;
                break;

            case 7:
                // handle confirm
                AdminDataManager.SetStrikeReason(Autofill.Id, 2, Strike2Reason7, BotUtils.GetGUser(Context));
                PageNum = 14;
                break;

            case 8:
                // handle confirm
                AdminDataManager.SetStrikeReason(Autofill.Id, 3, BanReason8, BotUtils.GetGUser(Context));
                PageNum = 14;
                break;

            case 9:
                // HC
                if (Autofill != null)
                {
                    UserId          = Autofill.Id.ToString();
                    FullUsername    = BotUtils.GetFullUsername(Autofill);
                    Strike1Reason11 = AdminDataManager.GetStrikeReason(Autofill.Id, 1);
                    Strike2Reason12 = AdminDataManager.GetStrikeReason(Autofill.Id, 2);
                    BanReason13     = AdminDataManager.GetStrikeReason(Autofill.Id, 3);
                }
                else
                {
                    return;     // you must specify a user
                }

                PageNum = 10;
                break;

            case 10:
                switch (OpCursor + 1)
                {
                case 1:
                    PageNum = 11;
                    break;

                case 2:
                    PageNum = 12;
                    break;

                case 3:
                    PageNum = 13;
                    break;
                }
                break;

            case 11:
                // handle confirm
                AdminDataManager.DeleteStrike(Autofill.Id, 1);
                PageNum = 14;
                break;

            case 12:
                // handle confirm
                AdminDataManager.DeleteStrike(Autofill.Id, 2);
                PageNum = 14;
                break;

            case 13:
                // handle confirm
                AdminDataManager.DeleteStrike(Autofill.Id, 3);
                PageNum = 14;
                break;
            }
        }