public override async Task ButtonAction(SocketReaction action) { switch (action.Emote.ToString()) { case ReactionHandler.CHECK_STR: // On confirm if (!AllFieldsFilled()) { return; // Do nothing if the fields are not filled. } // otherwise, add the strike. StrikeDataNode str = new StrikeDataNode(Context.User, Reason); int strikes = AdminDataManager.AddStrike(Target, str); if (strikes >= 3) { await Context.Channel.SendMessageAsync(BotUtils.KamtroText($"{BotUtils.GetFullUsername(Target)} has 3 strikes")); break; } await Context.Channel.SendMessageAsync(BotUtils.KamtroText($"Added strike for {BotUtils.GetFullUsername(Target)}. They now have {strikes} strike{((strikes == 1) ? "":"s")}.")); if (notifyUser) { bool sent = await BotUtils.DMUserAsync(BotUtils.GetGUser(Target.Id), new StrikeNotifyEmbed(str.Reason, strikes).GetEmbed()); if (!sent) { await Context.Channel.SendMessageAsync(BotUtils.BadDMResponse); } } break; case diamond: // toggles the notification of the user notifyUser = !notifyUser; await UpdateEmbed(); return; } EventQueueManager.RemoveMessageEvent(this); // now remove the event }
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; } }