Ejemplo n.º 1
0
        public async Task DailyPoints()
        {
            string        currentDate = DateTime.Now.ToString("yyyyMMdd");
            DailyPoints   dailyPoints = ObjectUtils.GetDailyPoints("_id", currentDate);
            var           user        = Context.Message.Author;
            List <string> users       = dailyPoints.users.ToList();

            if (users.Contains(user.ToString()))
            {
                TimeSpan untilReset = DateTime.Today.AddDays(1) - DateTime.Now;
                await ReplyAsync($"{user} has already reclaimed the daily points.\nClaim points in {untilReset.Hours}h {untilReset.Minutes}m");
            }
            else
            {
                Util.UpdateArray("_id", currentDate, "users", user.ToString(), "dailyPoints");
                Random rand    = new Random();
                var    points  = rand.Next(MIN_DAILY_POINTS, MAX_DAILY_POINTS + 1);
                var    jackpot = rand.Next(MIN_DAILY_POINTS, MAX_DAILY_POINTS + 1);
                await RoleUtils.DailyPointsRoles(user as SocketGuildUser, Context.Message.Channel.Id, MIN_DAILY_POINTS, MAX_DAILY_POINTS, points, jackpot);

                if (points.Equals(jackpot))
                {
                    points *= JACKPOT_MULTIPLIER;
                    await ReplyAsync($"{user} has hit the __***JACKPOT!***__");
                }
                DatabaseUtils.IncrementDocument(user.Id, "points", points);
                await ReplyAsync($"{user} earned {points} points!");
            }
        }