Esempio n. 1
0
        public static void WarnUser(SocketUser user, float size, string reason, string location)
        {
            List <Infraction> infractions = LoadInfractions(location);

            Infraction newInfraction = new Infraction {
                reason = reason,
                time   = DateTime.Now,
                size   = size
            };

            infractions.Add(newInfraction);

            SaveInfractions(location, infractions);
        }
Esempio n. 2
0
        public static Embed CheckInfractions(SocketUser user, string location)
        {
            List <Infraction> infractions = LoadInfractions(location);

            string infractionList    = "";
            float  infractionsToday  = 0;
            float  infractions30Days = 0;
            float  totalInfractions  = 0;
            float  last7Days         = 0;
            string plural            = "";

            for (int i = 0; i < infractions.Count; i++)
            {
                if (i != 0)   //Creates new line if it's not the first infraction
                {
                    infractionList += "\n";
                }
                Infraction infraction = infractions[i];

                //Gets how long ago all the infractions were
                int    daysAgo = (DateTime.Now.Date - infraction.time.Date).Days;
                string timeAgo;
                totalInfractions += infraction.size;
                timeAgo           = DateTime.Now.Month - infraction.time.Month + " months ago";

                if (daysAgo <= 7)
                {
                    last7Days += infraction.size;
                }
                if (daysAgo <= 30)
                {
                    if (DateTime.Now.Day - infraction.time.Day == 1)
                    {
                        plural = "";
                    }
                    else
                    {
                        plural = "s";
                    }
                    infractions30Days += infraction.size;
                    timeAgo            = DateTime.Now.Day - infraction.time.Day + " day" + plural + " ago";
                    if (infraction.time.Date == DateTime.Now.Date)
                    {
                        infractionsToday += infraction.size;
                        if (DateTime.Now.Hour - infraction.time.Hour == 1)
                        {
                            plural = "";
                        }
                        else
                        {
                            plural = "s";
                        }
                        timeAgo = DateTime.Now.Hour - infraction.time.Hour + " hour" + plural + " ago";
                        if (infraction.time.Hour == DateTime.Now.Hour)
                        {
                            if (DateTime.Now.Minute - infraction.time.Minute == 1)
                            {
                                plural = "";
                            }
                            else
                            {
                                plural = "s";
                            }
                            timeAgo = DateTime.Now.Minute - infraction.time.Minute + " minute" + plural + " ago";
                            if (infraction.time.Minute == DateTime.Now.Minute)
                            {
                                if (DateTime.Now.Second - infraction.time.Second == 1)
                                {
                                    plural = "";
                                }
                                else
                                {
                                    plural = "s";
                                }
                                timeAgo = DateTime.Now.Second - infraction.time.Second + " second" + plural + " ago";
                            }
                        }
                    }
                }

                string size = "";
                if (infraction.size != 1)
                {
                    size = "[" + infraction.size + "x] ";
                }

                infractionList += size + infraction.reason + " - " + timeAgo;
            }

            if (infractions.Count > 1)
            {
                plural = "s";
            }
            else
            {
                plural = "";
            }

            //Builds infraction embed
            var embed = new EmbedBuilder();

            embed.AddField("Today",
                           infractionsToday, true);
            embed.AddField("Last 7 days",
                           last7Days, true);
            embed.AddField("Last 30 days",
                           infractions30Days, true);
            embed.AddField("Warning" + plural + " (total " + totalInfractions + " sum of size & " + infractions.Count + " individual)",
                           infractionList)
            .WithAuthor(user)
            .WithColor(Color.Blue)
            .WithCurrentTimestamp();
            return(embed.Build());
        }