예제 #1
0
        public async Task DailyCmd()
        {
            bool  newDaily = false;
            Daily daily    = DailyDb.GetDaily(Context.User.Id, Context.Guild.Id);

            if (daily == null)
            {
                daily = new Daily
                {
                    UserId  = Context.User.Id,
                    GuildId = Context.Guild.Id,
                    Date    = 0
                };
                newDaily = true;
            }

            long timeNow = DateTimeOffset.Now.ToUnixTimeMilliseconds();
            int  ms      = 72000000;

            if (PremiumDb.IsPremium(Context.User.Id, ProType.ProPlus))
            {
                ms /= 2;
            }

            if ((daily.Date + ms) < timeNow)
            {
                if ((daily.Date + 172800000) < timeNow && !newDaily)
                {
                    long   mslate     = timeNow - (daily.Date + 172800000);
                    long   dayslate   = (mslate / (1000 * 60 * 60 * 24)) + 1;
                    double multiplier = dayslate > 3 ? 0 : 1 - dayslate * 0.25;
                    daily.Streak = (int)(daily.Streak * multiplier);
                    await ReplyAsync($"You are **{dayslate}** days late to claim your daily. For every day missed, you lose 25% of your streak.");
                }

                daily.Streak++;
                daily.Date = timeNow;
                int amount = ToastieUtil.DailyAmount(daily.Streak);
                int tax    = ToastieUtil.DailyTax(amount, BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id), BalanceDb.GetToasties(Context.Client.CurrentUser.Id, Context.Guild.Id), await BalanceDb.TotalToasties(Context.Guild.Id));
                amount -= tax / 2;
                //int cap = Constants.dailycap;
                //amount = amount > cap ? cap : amount;

                await DailyDb.SetDaily(daily);

                await BalanceDb.AddToasties(Context.User.Id, amount, Context.Guild.Id);

                await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, tax, Context.Guild.Id);

                await Context.Channel.SendMessageAsync("", false, ToastieUtil.DailyGetEmbed(Context.User, daily.Streak, amount, BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id), Program.GetPrefix(Context)).Build());
            }
            else
            {
                long wait    = (daily.Date + ms - timeNow) / 1000;
                int  hours   = (int)wait / 3600;
                int  minutes = (int)wait % 3600 / 60;
                int  seconds = (int)wait % 60;
                await Context.Channel.SendMessageAsync("", false, ToastieUtil.DailyWaitEmbed(Context.User, hours, minutes, seconds, Program.GetPrefix(Context)).Build());
            }
        }
예제 #2
0
        public async Task Weekly()
        {
            var weekly = WeeklyDb.GetWeekly(Context.User.Id, Context.Guild.Id);

            if (weekly == null)
            {
                weekly = new Weekly
                {
                    GuildId = Context.Guild.Id,
                    UserId  = Context.User.Id
                };
            }

            int hours = 164;

            if (PremiumDb.IsPremium(Context.Guild.Id, ProType.Guild) || PremiumDb.IsPremium(Context.Guild.Id, ProType.GuildPlus))
            {
                hours /= 2;
            }

            if (weekly.Date.AddHours(hours).CompareTo(DateTime.Now) < 0)
            {
                int streak = await DailyDb.GetHighest(Context.Guild.Id) + 15;

                int amount = ToastieUtil.DailyAmount(streak);
                int tax    = ToastieUtil.DailyTax(amount, BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id), BalanceDb.GetToasties(Context.Client.CurrentUser.Id, Context.Guild.Id), await BalanceDb.TotalToasties(Context.Guild.Id));
                amount -= tax / 2;
                if (PremiumDb.IsPremium(Context.Guild.Id, ProType.GuildPlus))
                {
                    amount += 1000;
                }

                string text = "";
                if (PremiumDb.IsPremium(Context.User.Id, ProType.ProPlus))
                {
                    await LootBoxDb.AddLootbox(Context.User.Id, LootBoxType.WaifuT1, 1, Context.Guild.Id);

                    text = "You receive a T1 Waifu lootbox! :star2:";
                }

                await BalanceDb.AddToasties(Context.User.Id, amount, Context.Guild.Id);

                await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, tax / 2, Context.Guild.Id);

                weekly.Date = DateTime.Now;
                await WeeklyDb.SetWeekly(weekly);

                await Context.Channel.SendMessageAsync(text, false, ToastieUtil.WeeklyGetEmbed(amount, BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id), Context.User, Program.GetPrefix(Context)).Build());

                return;
            }

            await Context.Channel.SendMessageAsync("", false, ToastieUtil.WeeklyWaitEmbed(weekly.Date.AddHours(hours), Context.User, Program.GetPrefix(Context)).Build());
        }