Example #1
0
        public async Task My_Points()
        {
            var violator = await _mongo.GetCollection <Violator>(Context.Client).GetUserAsync(Context.Guild.Id, Context.User.Id);

            var penalties = await _mongo.GetCollection <Penalty>(Context.Client).GetPenaltiesAsync(Context.Guild.Id);

            violator = await Violations.TryDecreasePoints(Context, violator);

            var nextPenalty = penalties.OrderBy(p => p.RequiredPoints).FirstOrDefault(penalty => penalty.RequiredPoints > violator.Points);

            var until = TimeSpan.Zero;

            if (violator.Points > 0)
            {
                until = violator.LatestViolation.AddHours(_config.PointDecreaseHours) - DateTime.UtcNow;
            }
            await ReplyAsync(
                // ReSharper disable once UseFormatSpecifierInInterpolation
                $"You currently have {violator.Points} points. {(until != TimeSpan.Zero ? $"You will lose one point in {until.ToString(@"hh'h'\:mm'm'\:ss's'")}" : "")}" +
                $"{(nextPenalty != null ? $"\nThe next Penalty*({nextPenalty.PenaltyType})* is at {nextPenalty.RequiredPoints} points" : "")}");
        }