Beispiel #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());
            }
        }
Beispiel #2
0
        public async Task Give(IUser recipient, string sAmount, [Remainder] string str = "")
        {
            int amount = ToastieUtil.ParseAmount(sAmount, (SocketGuildUser)Context.User);

            if (amount < 0)
            {
                await Context.Channel.SendMessageAsync("Pick an amount! number, all, half, or x/y.");

                return;
            }
            if (amount == 0)
            {
                await Context.Channel.SendMessageAsync("You have no toasties...");

                return;
            }

            try
            {
                await BalanceDb.AddToasties(Context.User.Id, -amount, Context.Guild.Id);
            }
            catch (Exception ex)
            {
                await Context.Channel.SendMessageAsync(ex.Message);

                return;
            }

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

            await Context.Channel.SendMessageAsync("", false, ToastieUtil.GiveEmbed(Context.User, recipient, amount).Build());
        }
Beispiel #3
0
 public async Task Toastie([Remainder] IUser user = null)
 {
     if (user == null)
     {
         user = Context.User;
     }
     await Context.Channel.SendMessageAsync("", false, ToastieUtil.ToastieEmbed(user, BalanceDb.GetToasties(user.Id, Context.Guild.Id)).Build());
 }
Beispiel #4
0
        public static EmbedBuilder ToastieEmbed(IUser user, int amount)
        {
            var eb = new EmbedBuilder();

            eb.WithAuthor(user);
            eb.WithDescription($"You have **{amount.ToString("n0")}** {ToastieUtil.RandomEmote()}!");
            eb.WithColor(Color.Gold);
            return(eb);
        }
Beispiel #5
0
        public static EmbedBuilder FlipLoseEmbed(SocketGuildUser user, int amount)
        {
            var eb = new EmbedBuilder();

            eb.WithAuthor(user);
            eb.WithDescription($"**You lose!** {amount.ToString("n0")} {ToastieUtil.RandomEmote()} lost...\nNow you have {BalanceDb.GetToasties(user.Id, user.Guild.Id).ToString("n0")} {ToastieUtil.RandomEmote()}!");
            eb.WithColor(Color.DarkRed);
            return(eb);
        }
Beispiel #6
0
        public async Task SellWaifu([Remainder] string str = "")
        {
            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(str, false, UserInventoryDb.GetWaifus(Context.User.Id, Context.Guild.Id)), this);

            //waifus existance
            if (waifu == null)
            {
                return;
            }

            int worth = WaifuUtil.GetSalePrice(waifu.Tier);

            var sell = new DialogueBoxOption();

            sell.Action = async(IUserMessage message) =>
            {
                if (!UserInventoryDb.OwnsWaifu(Context.User.Id, waifu, Context.Guild.Id))
                {
                    await message.ModifyAsync(x => {
                        x.Embed = new EmbedBuilderPrepared(Context.User).WithDescription("You tried :star:").Build();
                    });

                    return;
                }

                try { await BalanceDb.AddToasties(Context.User.Id, worth, Context.Guild.Id); }
                catch (Exception ex) { await Context.Channel.SendMessageAsync(ex.Message); }

                //removing waifu + confirmation
                await UserInventoryDb.DeleteWaifu(Context.User.Id, waifu, Context.Guild.Id);

                await message.ModifyAsync(x => {
                    x.Content = $"You sold **{waifu.Name}** for **{worth.ToString("n0")}** toasties.";
                    x.Embed   = ToastieUtil.ToastieEmbed(Context.User, BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id)).Build();
                });
            };
            sell.After = OnExecute.RemoveReactions;

            var cancel = new DialogueBoxOption();

            cancel.After = OnExecute.Delete;

            var dia = new DialogueBox();

            dia.Options.Add(Emote.Parse("<:TickYes:577838859107303424>"), sell);
            dia.Options.Add(Emote.Parse("<:TickNo:577838859077943306>"), cancel);
            dia.Timeout = new TimeSpan(0, 1, 0);
            dia.Embed   = new EmbedBuilder()
                          .WithAuthor(Context.User)
                          .WithColor(BasicUtil.RandomColor())
                          .WithDescription($"Sell **{waifu.Name}** for **{worth.ToString("n0")}** toasties?").Build();

            await DialogueReplyAsync(dia);

            return;
        }
Beispiel #7
0
        public async Task BlackjackCommand(string sAmount, [Remainder] string str = "")
        {
            var user = (SocketGuildUser)Context.User;
            var ch   = (SocketTextChannel)Context.Channel;

            if (Blackjack.games.ContainsKey(Context.User))
            {
                await Context.Channel.SendMessageAsync("You are already in a game of blackjack. #" + Blackjack.games[user].Channel.Name);

                return;
            }

            int amount = ToastieUtil.ParseAmount(sAmount, user);

            if (amount < 0)
            {
                await Context.Channel.SendMessageAsync("Pick an amount! number, all, half, or x/y.");

                return;
            }
            if (amount == 0)
            {
                await Context.Channel.SendMessageAsync("You have no toasties...");

                return;
            }

            try
            {
                await BalanceDb.AddToasties(user.Id, -amount, Context.Guild.Id);
            }
            catch (Exception e)
            {
                await ch.SendMessageAsync(e.Message);

                return;
            }

            if (BalanceDb.GetToasties(Context.Client.CurrentUser.Id, Context.Guild.Id) < amount)
            {
                string prefix = Program.GetPrefix(Context);
                await Context.Channel.SendMessageAsync("Tch, I don't have enough toasties... I will recover eventually by stealing toasties from all of you. :fox:" +
                                                       $"But if you want to speed up the process you can give me some using the `{prefix}give` or `{prefix}at` commands.");

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

                return;
            }

            BlackjackGame game = new BlackjackGame(amount, ch);

            Blackjack.games[user] = game;
            await Blackjack.GameContinue(Context, game);
        }
Beispiel #8
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());
        }
Beispiel #9
0
        public async Task Lootboxes([Remainder] IUser user = null)
        {
            user ??= Context.User;

            var boxes = await LootBoxDb.GetAll(user.Id, Context.Guild.Id);

            if (boxes.Count == 0)
            {
                await Context.Channel.SendMessageAsync("", false, ToastieUtil.NoBoxEmbed(user).Build());

                return;
            }

            await Context.Channel.SendMessageAsync(embed : ToastieUtil.BoxListEmbed(boxes, user).WithDescription("").Build());
        }
Beispiel #10
0
        public static EmbedBuilder DailyGetEmbed(IUser user, int streak, int amount, int balance, string prefix)
        {
            var eb = new EmbedBuilder();

            eb.WithAuthor(user.ToString(), user.GetAvatarUrl(), LinkHelper.GetRedirectUrl(LinkHelper.Patreon, "Patreon", "cmd-embed-daily"));
            eb.WithDescription($"You're on a **{streak.ToString("n0")}** day streak. You receive **{amount.ToString("n0")}** {ToastieUtil.RandomEmote()}\n" +
                               $"Now you have **{balance.ToString("n0")}** {ToastieUtil.RandomEmote()}\n\n" +
                               $"Vote for me on [Discord Bots]({LinkHelper.GetRedirectUrl(LinkHelper.Vote, "Vote", "cmd-daily")}) every day to receive a lootbox!");
            eb.WithColor(BasicUtil.RandomColor());

            if (!(PremiumDb.IsPremium(user.Id, ProType.Pro) || PremiumDb.IsPremium(user.Id, ProType.ProPlus)))
            {
                eb.WithFooter($"Check out Pro upgrades! `{prefix}Pro`");
            }
            return(eb);
        }
Beispiel #11
0
        public async Task BRRewardPool(string amountStr)
        {
            int amount = ToastieUtil.ParseAmount(amountStr, (SocketGuildUser)Context.User);

            if (amount < 0)
            {
                await Context.Channel.SendMessageAsync("Pick an amount! number, all, half, or x/y.");

                return;
            }
            if (amount == 0)
            {
                await Context.Channel.SendMessageAsync("You have no toasties...");

                return;
            }

            var banroulette = BanrouletteDb.GetBanroulette(Context.Channel.Id);

            if (banroulette == null)
            {
                await Context.Channel.SendMessageAsync(":x: There is no running Ban Roulette in this channel.");

                return;
            }

            try
            {
                await BalanceDb.AddToasties(Context.User.Id, -amount, Context.Guild.Id);
            }
            catch (Exception ex)
            {
                await Context.Channel.SendMessageAsync(ex.Message);

                return;
            }

            banroulette.RewardPool += amount;
            await BanrouletteDb.UpdateBanroulette(banroulette);

            await Context.Channel.SendMessageAsync($"Added {amount} to the reward pool!");
        }
Beispiel #12
0
        public async Task Beg([Remainder] string str = "")
        {
            var amount = BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id);

            if (amount > 0)
            {
                await Context.Channel.SendMessageAsync("You already have toasties, you snob.");

                return;
            }

            if (!Constants.beg)
            {
                await Context.Channel.SendMessageAsync(ToastieUtil.GetFalseBegMessage());

                return;
            }

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

            await Context.Channel.SendMessageAsync("Fine. Just leave me alone.", false, ToastieUtil.GiveEmbed(Context.Client.CurrentUser, Context.User, amount).Build());
        }
Beispiel #13
0
        public static async Task GameTimeout(SocketUser user, BlackjackGame game)
        {
            {
                EmbedBuilder eb  = new EmbedBuilder();
                var          bot = game.Message.Author.Id;

                game.Stand();

                if (game.SumHand(game.Hand) > 21)
                {
                    await BalanceDb.AddToasties(bot, game.Toasties, game.Channel.Guild.Id);

                    eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl());
                    eb.WithDescription("Your hand is a bust. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" +
                                       "New balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote());
                    eb.WithColor(Color.DarkRed);
                }

                else if (game.SumHand(game.Hand) > game.SumHand(game.Dealer) || game.SumHand(game.Dealer) > 21)
                {
                    await BalanceDb.AddToasties(user.Id, game.Toasties * 2, game.Channel.Guild.Id);

                    await BalanceDb.AddToasties(bot, -game.Toasties, game.Channel.Guild.Id);

                    eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl());
                    eb.WithDescription("Your score is higher than Namiko's. You win `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" +
                                       "New balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote());
                    eb.WithColor(Color.Gold);
                }

                else if (game.SumHand(game.Hand) == game.SumHand(game.Dealer))
                {
                    await BalanceDb.AddToasties(user.Id, game.Toasties, game.Channel.Guild.Id);

                    eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl());
                    eb.WithDescription("Your score is tied with Namiko's. You get your " + ToastieUtil.RandomEmote() + " back!\n" +
                                       "Your balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote());
                    eb.WithColor(Color.DarkGreen);
                }

                else
                {
                    await BalanceDb.AddToasties(bot, game.Toasties, game.Channel.Guild.Id);

                    eb.WithAuthor(user.Username + " | Timeout", user.GetAvatarUrl());
                    eb.WithDescription("Namiko's score is higher. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" +
                                       "New balance `" + BalanceDb.GetToasties(user.Id, game.Channel.Guild.Id) + "` " + ToastieUtil.RandomEmote());
                    eb.WithColor(Color.DarkRed);
                }

                eb.AddField("Your hand (" + game.SumHand(game.Hand) + ")", HandToString(game.Hand, false), true);
                eb.AddField("Namiko's hand (" + game.SumHand(game.Dealer) + ")", HandToString(game.Dealer, false), true);

                await Send(game, eb);

                games.Remove(user);
            }
        }
Beispiel #14
0
        public async Task BulkOpen([Remainder] string str = "")
        {
            var boxes = await LootBoxDb.GetAll(Context.User.Id, Context.Guild.Id);

            if (boxes.Count == 0)
            {
                await Context.Channel.SendMessageAsync("", false, ToastieUtil.NoBoxEmbed(Context.User).Build());

                return;
            }

            LootBox box = null;

            if (boxes.Count == 1)
            {
                box = boxes[0];
            }

            else
            {
                var listMsg = await Context.Channel.SendMessageAsync(embed : ToastieUtil.BoxListEmbed(boxes, Context.User)
                                                                     .WithFooter("Times out in 23 seconds")
                                                                     .WithDescription("Enter the number of the Lootbox type you wish to open.")
                                                                     .Build());

                var response = await NextMessageAsync(
                    new Criteria <IMessage>()
                    .AddCriterion(new EnsureSourceUserCriterion())
                    .AddCriterion(new EnsureSourceChannelCriterion())
                    .AddCriterion(new EnsureRangeCriterion(boxes.Count, Program.GetPrefix(Context))),
                    new TimeSpan(0, 0, 23));

                _ = listMsg.DeleteAsync();
                int i = 0;
                try
                {
                    i = int.Parse(response.Content);
                }
                catch
                {
                    _ = Context.Message.DeleteAsync();
                    return;
                }
                _ = response.DeleteAsync();

                box = boxes[i - 1];
            }

            var type      = LootboxStats.Lootboxes[box.Type];
            var dialoague = await ReplyAsync(embed : new EmbedBuilderPrepared(Context.User).WithDescription($"How many {type.Emote} **{type.Name}** lootboxes do you wish to open?").Build());

            var amountMsg = await NextMessageAsync(
                new Criteria <IMessage>()
                .AddCriterion(new EnsureSourceUserCriterion())
                .AddCriterion(new EnsureSourceChannelCriterion())
                .AddCriterion(new EnsureRangeCriterion(int.MaxValue, Program.GetPrefix(Context))),
                new TimeSpan(0, 0, 23));

            int amount;

            try
            {
                amount = int.Parse(amountMsg.Content);
            }
            catch
            {
                _ = Context.Message.DeleteAsync();
                return;
            }
            _ = dialoague.DeleteAsync();

            try
            {
                await LootBoxDb.AddLootbox(Context.User.Id, box.Type, -amount, box.GuildId);
            }
            catch
            {
                await Context.Channel.SendMessageAsync("You tried.");

                return;
            }
            _ = amountMsg.DeleteAsync();

            var msg = await Context.Channel.SendMessageAsync("", false, ToastieUtil.BoxOpeningEmbed(Context.User).Build());

            await ProfileDb.IncrementLootboxOpened(Context.User.Id, amount);

            int waitms = 4200;

            int  toasties    = 0;
            var  waifusFound = new List <Waifu>();
            var  waifus      = UserInventoryDb.GetWaifus(Context.User.Id, Context.Guild.Id);
            bool isPremium   = PremiumDb.IsPremium(Context.User.Id, ProType.Pro);

            for (int i = 0; i < amount; i++)
            {
                if (type.IsWaifu())
                {
                    var waifu = await ToastieUtil.UnboxWaifu(type, isPremium, Context.User.Id, Context.Guild.Id);

                    while (waifu == null || waifus.Any(x => x.Name.Equals(waifu.Name)) || waifusFound.Any(x => x.Name.Equals(waifu.Name)))
                    {
                        waifu = await ToastieUtil.UnboxWaifu(type, isPremium, Context.User.Id, Context.Guild.Id);
                    }

                    waifusFound.Add(waifu);
                    await UserInventoryDb.AddWaifu(Context.User.Id, waifu, Context.Guild.Id);
                }
                else
                {
                    toasties += type.GetRandomToasties();
                }
            }

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

            var bal = BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id);

            await Task.Delay(waitms);

            var eb = new EmbedBuilder()
                     .WithAuthor($"{Context.User} | {box.Type.ToString()} x{amount}", Context.User.GetAvatarUrl(), LinkHelper.GetRedirectUrl(LinkHelper.Patreon, "Patreon", "cmd-embed-lootbox"))
                     .WithColor(BasicUtil.RandomColor())
                     .WithThumbnailUrl("https://i.imgur.com/4JQmxa6.png");

            string desc = $"You found **{toasties.ToString("n0")}** {ToastieUtil.RandomEmote()}!\nNow you have **{bal.ToString("n0")}** {ToastieUtil.RandomEmote()}!\n\n";

            if (waifusFound.Any())
            {
                desc += "**Waifus Found:**\n";
                foreach (var w in waifusFound)
                {
                    desc += $"`T{w.Tier}` **{w.Name}** - *{(w.Source.Length > 37 ? w.Source.Substring(0, 33) + "..." : w.Source)}*\n";
                }
            }

            eb.WithDescription(desc.Length > 2000 ? desc.Substring(0, 1970) + "\n*And more...*" : desc);
            await msg.ModifyAsync(x => {
                x.Embed = eb.Build();
            });
        }
Beispiel #15
0
        public async Task Open([Remainder] string str = "")
        {
            var boxes = await LootBoxDb.GetAll(Context.User.Id, Context.Guild.Id);

            if (boxes.Count == 0)
            {
                await Context.Channel.SendMessageAsync("", false, ToastieUtil.NoBoxEmbed(Context.User).Build());

                return;
            }

            LootBox box = null;

            if (boxes.Count == 1)
            {
                box = boxes[0];
            }

            else
            {
                var listMsg = await Context.Channel.SendMessageAsync(embed : ToastieUtil.BoxListEmbed(boxes, Context.User)
                                                                     .WithFooter("Times out in 23 seconds")
                                                                     .WithDescription("Enter the number of the Lootbox you wish to open.")
                                                                     .Build());

                var response = await NextMessageAsync(
                    new Criteria <IMessage>()
                    .AddCriterion(new EnsureSourceUserCriterion())
                    .AddCriterion(new EnsureSourceChannelCriterion())
                    .AddCriterion(new EnsureRangeCriterion(boxes.Count, Program.GetPrefix(Context))),
                    new TimeSpan(0, 0, 23));

                _ = listMsg.DeleteAsync();
                int i = 0;
                try
                {
                    i = int.Parse(response.Content);
                }
                catch
                {
                    _ = Context.Message.DeleteAsync();
                    return;
                }
                _ = response.DeleteAsync();

                box = boxes[i - 1];
            }

            var type = LootboxStats.Lootboxes[box.Type];

            try
            {
                await LootBoxDb.AddLootbox(Context.User.Id, box.Type, -1, box.GuildId);
            } catch
            {
                await Context.Channel.SendMessageAsync("You tried.");

                return;
            }
            var msg = await Context.Channel.SendMessageAsync("", false, ToastieUtil.BoxOpeningEmbed(Context.User).Build());

            await ProfileDb.IncrementLootboxOpened(Context.User.Id);

            int waitms = 4200;

            if (type.IsWaifu())
            {
                bool isPremium = PremiumDb.IsPremium(Context.User.Id, ProType.Pro);
                var  waifu     = await ToastieUtil.UnboxWaifu(type, isPremium, Context.User.Id, Context.Guild.Id);

                while (UserInventoryDb.OwnsWaifu(Context.User.Id, waifu, Context.Guild.Id))
                {
                    waifu = await ToastieUtil.UnboxWaifu(type, isPremium, Context.User.Id, Context.Guild.Id);
                }

                await UserInventoryDb.AddWaifu(Context.User.Id, waifu, Context.Guild.Id);

                await Task.Delay(waitms);

                var embed = WaifuUtil.WaifuEmbedBuilder(waifu, Context).Build();
                await msg.ModifyAsync(x => {
                    x.Embed   = embed;
                    x.Content = $"{Context.User.Mention} Congratulations! You found **{waifu.Name}**!";
                });

                return;
            }

            var amountWon = type.GetRandomToasties();
            await BalanceDb.AddToasties(Context.User.Id, amountWon, Context.Guild.Id);

            var bal = BalanceDb.GetToasties(Context.User.Id, Context.Guild.Id);
            await Task.Delay(waitms);

            await msg.ModifyAsync(x => {
                x.Embed = new EmbedBuilder()
                          .WithAuthor($"{Context.User} | {box.Type.ToString()}", Context.User.GetAvatarUrl(), LinkHelper.GetRedirectUrl(LinkHelper.Patreon, "Patreon", "cmd-embed-lootbox"))
                          .WithColor(BasicUtil.RandomColor())
                          .WithThumbnailUrl("https://i.imgur.com/4JQmxa6.png")
                          .WithDescription($"Congratulations! You found **{amountWon.ToString("n0")}** {ToastieUtil.RandomEmote()}!\nNow you have **{bal.ToString("n0")}** {ToastieUtil.RandomEmote()}!")
                          .Build();
            });
        }
Beispiel #16
0
 public async Task ShowLootboxStats([Remainder] string str = "")
 {
     await ReplyAsync(embed : ToastieUtil.BoxStatsEmbed(Context.User).Build());
 }
Beispiel #17
0
 public async Task LootboxShop([Remainder] string str = "")
 {
     await Context.Channel.SendMessageAsync(embed : ToastieUtil.BoxShopEmbed(Context.User).Build());
 }
Beispiel #18
0
        public async Task Add(IUser user, int amount, [Remainder] string str = "")
        {
            await BalanceDb.AddToasties(user.Id, amount, Context.Guild.Id);

            await Context.Channel.SendMessageAsync("", false, ToastieUtil.ToastieEmbed(user, BalanceDb.GetToasties(user.Id, Context.Guild.Id)).Build());
        }
Beispiel #19
0
        public static async Task GameEnd(SocketCommandContext Context, BlackjackGame game)
        {
            EmbedBuilder eb   = new EmbedBuilder();
            var          user = Context.User;

            if (game.SumHand(game.Hand) > 21)
            {
                await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, game.Toasties, Context.Guild.Id);

                eb.WithAuthor(user.Username + " | You Lose", user.GetAvatarUrl());
                eb.WithDescription("Your hand is a bust. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" +
                                   "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote());
                eb.WithColor(Color.DarkRed);
            }

            else if (game.SumHand(game.Hand) > game.SumHand(game.Dealer) || game.SumHand(game.Dealer) > 21)
            {
                await BalanceDb.AddToasties(user.Id, game.Toasties * 2, Context.Guild.Id);

                await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, -game.Toasties, Context.Guild.Id);

                eb.WithAuthor(user.Username + " | You Win", user.GetAvatarUrl());
                eb.WithDescription("Your score is higher than Namiko's. You win `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" +
                                   "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote());
                eb.WithColor(Color.Gold);
            }

            else if (game.SumHand(game.Hand) == game.SumHand(game.Dealer))
            {
                await BalanceDb.AddToasties(user.Id, game.Toasties, Context.Guild.Id);

                eb.WithAuthor(user.Username + " | Tie", user.GetAvatarUrl());
                eb.WithDescription("Your score is tied with Namiko's. You get your " + ToastieUtil.RandomEmote() + " back!\n" +
                                   "Your balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote());
                eb.WithColor(Color.DarkGreen);
            }

            else
            {
                await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, game.Toasties, Context.Guild.Id);

                eb.WithAuthor(user.Username + " | You Lose", user.GetAvatarUrl());
                eb.WithDescription("Namiko's score is higher. You lose `" + game.Toasties + "` " + ToastieUtil.RandomEmote() + "\n" +
                                   "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "` " + ToastieUtil.RandomEmote());
                eb.WithColor(Color.DarkRed);
            }

            eb.AddField("Your hand (" + game.SumHand(game.Hand) + ")", HandToString(game.Hand, false), true);
            eb.AddField("Namiko's hand (" + game.SumHand(game.Dealer) + ")", HandToString(game.Dealer, false), true);

            await Send(game, eb);

            games.Remove(user);
        }
Beispiel #20
0
        public static async Task Forfeit(SocketCommandContext Context, BlackjackGame game)
        {
            var user = Context.User;

            await BalanceDb.AddToasties(user.Id, game.Toasties / 2, Context.Guild.Id);

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

            EmbedBuilder eb = new EmbedBuilder();

            eb.WithAuthor(user.Username + " | You Lose", null, user.GetAvatarUrl());
            eb.WithDescription("You forfeit. You get half your toasties back. Lost `" + game.Toasties / 2 + "`" + ToastieUtil.RandomEmote() + "\n" +
                               "New balance `" + BalanceDb.GetToasties(user.Id, Context.Guild.Id) + "`" + ToastieUtil.RandomEmote());
            eb.AddField("Your hand (" + game.SumHand(game.Hand) + ")", HandToString(game.Hand, false), true);
            eb.AddField("Namiko's hand (" + game.SumHand(game.Dealer) + ")", HandToString(game.Dealer, false), true);
            eb.WithColor(Color.DarkBlue);

            await Send(game, eb);

            games.Remove(user);
        }
Beispiel #21
0
        public async Task Flip(string sAmount, string side = "t", [Remainder] string str = "")
        {
            var user = (SocketGuildUser)Context.User;
            var rnd  = new Random();

            side = side.ToLower();

            if (!(side.Equals("t") || side.Equals("h") || side.Equals("tails") || side.Equals("heads")))
            {
                await Context.Channel.SendMessageAsync("Pick heads or tails!");

                return;
            }

            int amount = ToastieUtil.ParseAmount(sAmount, user);

            if (amount < 0)
            {
                await Context.Channel.SendMessageAsync("Pick an amount! number, all, half, or x/y.");

                return;
            }
            if (amount == 0)
            {
                await Context.Channel.SendMessageAsync("You have no toasties...");

                return;
            }

            try
            {
                await BalanceDb.AddToasties(user.Id, -amount, Context.Guild.Id);
            }
            catch (Exception ex)
            {
                await Context.Channel.SendMessageAsync(ex.Message);

                return;
            }

            if (BalanceDb.GetToasties(Context.Client.CurrentUser.Id, Context.Guild.Id) < amount)
            {
                string prefix = Program.GetPrefix(Context);
                await Context.Channel.SendMessageAsync("Tch, I don't have enough toasties... I will recover eventually by stealing toasties from all of you. :fox:" +
                                                       $"But if you want to speed up the process you can give me some using the `{prefix}give` or `{prefix}at` commands.");

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

                return;
            }

            if (ToastieUtil.FiftyFifty())
            {
                await BalanceDb.AddToasties(user.Id, amount * 2, Context.Guild.Id);

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

                string resp = "";
                if (amount >= 50000 && rnd.Next(5) == 1)
                {
                    resp = "Tch... I'll get you next time.";
                }
                await Context.Channel.SendMessageAsync(resp, false, ToastieUtil.FlipWinEmbed(user, amount).Build());
            }
            else
            {
                await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, amount, Context.Guild.Id);

                string resp = "";
                if (amount >= 50000 && rnd.Next(5) == 1)
                {
                    resp = "I'll take those.";
                }
                await Context.Channel.SendMessageAsync(resp, false, ToastieUtil.FlipLoseEmbed(user, amount).Build());
            }
        }
Beispiel #22
0
        public async Task BuyLootbox([Remainder] string str = "")
        {
            var prefix = Program.GetPrefix(Context);

            if (!PremiumDb.IsPremium(Context.Guild.Id, ProType.GuildPlus))
            {
                await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User)
                                                       .WithDescription($"*~ This command requires Pro Guild+ ~*\n" +
                                                                        $"Try `{prefix}lootboxstats` to see drop rates.")
                                                       .WithFooter($"`{prefix}pro`")
                                                       .Build());

                return;
            }

            LootboxStat box   = null;
            var         boxes = LootboxStats.Lootboxes.Where(x => x.Value.Price >= 0).Select(x => x.Value).ToList();

            if (str != "")
            {
                var matches = boxes.Where(x => x.Name.Contains(str, StringComparison.OrdinalIgnoreCase));
                if (matches.Count() == 1)
                {
                    box = matches.First();
                }
            }
            if (box == null)
            {
                var listMsg = await Context.Channel.SendMessageAsync(embed : ToastieUtil.BoxShopEmbed(Context.User)
                                                                     .WithFooter("Times out in 23 seconds. Try the `lootboxstats` command")
                                                                     .WithDescription("Enter the number of the lootbox you wish to purchase.")
                                                                     .Build());

                var response = await NextMessageAsync(
                    new Criteria <IMessage>()
                    .AddCriterion(new EnsureSourceUserCriterion())
                    .AddCriterion(new EnsureSourceChannelCriterion())
                    .AddCriterion(new EnsureRangeCriterion(boxes.Count(), Program.GetPrefix(Context))),
                    new TimeSpan(0, 0, 23));

                _ = listMsg.DeleteAsync();
                int i = 0;
                try
                {
                    i = int.Parse(response.Content);
                }
                catch
                {
                    _ = Context.Message.DeleteAsync();
                    return;
                }
                _ = response.DeleteAsync();

                box = boxes[i - 1];
            }

            var msg = await Context.Channel.SendMessageAsync($"How many **{box.Name}** lootboxes do you wish to buy? (max 100)");

            var resp = await NextMessageAsync(
                new Criteria <IMessage>()
                .AddCriterion(new EnsureSourceUserCriterion())
                .AddCriterion(new EnsureSourceChannelCriterion())
                .AddCriterion(new EnsureRangeCriterion(100, Program.GetPrefix(Context))),
                new TimeSpan(0, 0, 23));

            _ = msg.DeleteAsync();
            int amount = 0;

            try
            {
                amount = int.Parse(resp.Content);
            }
            catch
            {
                _ = Context.Message.DeleteAsync();
                return;
            }
            _ = resp.DeleteAsync();

            try
            {
                await BalanceDb.AddToasties(Context.User.Id, -box.Price *amount, Context.Guild.Id);
            } catch (Exception ex)
            {
                await Context.Channel.SendMessageAsync(ex.Message);

                return;
            }

            await LootBoxDb.AddLootbox(Context.User.Id, (LootBoxType)box.TypeId, amount, Context.Guild.Id);

            await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User)
                                                   .WithDescription($"You bought {amount}x **{box.Name}**!\nType `{Program.GetPrefix(Context)}open` to open it!")
                                                   .Build());
        }
Beispiel #23
0
 public async Task Burn([Remainder] string str = "")
 {
     await Context.Channel.SendMessageAsync(ToastieUtil.GetFalseBegMessage());
 }
Beispiel #24
0
        public static EmbedBuilder GiveEmbed(IUser from, IUser to, int amount)
        {
            EmbedBuilder eb = new EmbedBuilder();

            eb.AddField("Toasties <:toastie3:454441133876183060>", $"{from.Username} gave {to.Username} **{amount.ToString("n0")}** {ToastieUtil.RandomEmote()}!");
            eb.WithColor(BasicUtil.RandomColor());
            return(eb);
        }