Beispiel #1
0
        public async Task EarnDaily()
        {
            // First lets try and get OR create the user because we're gonna need him
            User userDb = await _userRepo.GetOrCreateUser(Context.User.Id);

            var nextDailyPossible = userDb.LastDaily.AddHours(CoinModule.DAILY_COOLDOWN_HOURS);

            if (nextDailyPossible.CompareTo(DateTime.UtcNow) >= 0)
            {
                var timeRemaining = nextDailyPossible.Subtract(DateTime.UtcNow.TimeOfDay).TimeOfDay;
                await ReplyFailureEmbed(
                    $"You can't earn anymore right now. Please wait another {timeRemaining.Humanize(minUnit: TimeUnit.Second, precision: 2)}.");

                return;
            }

            // Otherwise we can earn
            if (await FailedTryTransaction(await _coinRepo.DoDaily(userDb.Id, DAILY_REWARD).ConfigureAwait(false)))
            {
                return;
            }

            await ReplySuccessEmbed(
                $"You gained {DAILY_REWARD} Sora Coins! You can earn again in {DAILY_COOLDOWN_HOURS}h.");
        }