Exemplo n.º 1
0
        public static async Task <Violator> TryDecreasePoints(ICommandContext context, Violator violator)
        {
            var decPoints = 0;
            var time      = violator.LatestViolation;

            while (DateTime.UtcNow > time)
            {
                if (DateTime.UtcNow > time.AddHours(_config.PointDecreaseHours))
                {
                    if (decPoints == violator.Points)
                    {
                        break;
                    }

                    time = time.AddHours(_config.PointDecreaseHours);
                    decPoints++;
                    violator.Points          = violator.Points - decPoints <= 0 ? 0 : violator.Points - decPoints;
                    violator.LatestViolation = time;
                }
                else
                {
                    break;
                }
            }
            Logger.Info($"Decreased {context.User}'s points({violator.Points + decPoints}) by {decPoints} for a total of {violator.Points}");
            await violator.SaveAsync();

            return(violator);
        }
Exemplo n.º 2
0
        private static async Task <Violator> IncreasePoint(ICommandContext context, Violator violator)
        {
            violator.LatestViolation = DateTime.UtcNow;
            violator.Points++;
            Logger.Info($"{context.User}'s Points {violator.Points - 1} => {violator.Points}");
            await violator.SaveAsync();

            return(violator);
        }