コード例 #1
0
        public async Task BuyWaifu([Remainder] string str = "")
        {
            var shopwaifus = (await WaifuShopDb.GetAllShopWaifus(Context.Guild.Id)).DistinctBy(x => x.WaifuName);

            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(str, false, shopwaifus.Select(x => x.Waifu)), this);

            if (waifu == null)
            {
                return;
            }
            var waifus = UserInventoryDb.GetWaifus(Context.User.Id, Context.Guild.Id);

            if (waifus.Any(x => x.Name.Equals(waifu.Name)))
            {
                await Context.Channel.SendMessageAsync("You already have **" + waifu.Name + "**.");

                return;
            }

            ShopWaifu shopWaifu = shopwaifus.FirstOrDefault(x => x.Waifu.Equals(waifu) && x.Limited != 0);

            if (shopWaifu == null)
            {
                await Context.Channel.SendMessageAsync($"**{waifu.Name}** is not currently for sale! Try the `waifushop` command.");

                return;
            }

            var price = WaifuUtil.GetPrice(waifu.Tier, shopWaifu.Discount);

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

                return;
            }

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

            await Context.Channel.SendMessageAsync($"Congratulations! You bought **{waifu.Name}**!", false, WaifuUtil.WaifuEmbedBuilder(waifu).Build());

            await BalanceDb.AddToasties(Context.Client.CurrentUser.Id, price / 13, Context.Guild.Id);

            if (shopWaifu.Limited > 0)
            {
                shopWaifu.BoughtBy = Context.User.Id;
                shopWaifu.Limited -= 1;
                await WaifuShopDb.UpdateItem(shopWaifu);
            }
        }
コード例 #2
0
        public async Task ModShopRemoveWaifu([Remainder] string name = "")
        {
            var shop = await WaifuUtil.GetShop(Context.Guild.Id, ShopType.Mod);

            var waifus = shop.ShopWaifus.Select(x => x.Waifu);

            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name, false, waifus), this);

            if (waifu == null)
            {
                return;
            }

            await WaifuShopDb.RemoveItem(shop.ShopWaifus.FirstOrDefault(x => x.Waifu.Name.Equals(waifu.Name)));

            await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User)
                                                   .WithDescription($"*~ **{waifu.Name}** removed from the Mod Shop ~*")
                                                   .Build());

            return;
        }
コード例 #3
0
ファイル: WaifuUtil.cs プロジェクト: ta1H3n/Namiko
        // Waifus Read/Write
        public static async Task<WaifuShop> GetShop(ulong guildId, ShopType type, bool overrideNew = false)
        {
            WaifuShop shop = null;
            try
            {
                shop = await WaifuShopDb.GetWaifuShop(guildId, type);
            }
            catch { }

            if (type == ShopType.Mod)
            {
                // Create mod shop if doesn't exist
                if (shop == null)
                {
                    shop = new WaifuShop
                    {
                        GeneratedDate = DateTime.Now,
                        GuildId = guildId,
                        Type = type,
                        ShopWaifus = new List<ShopWaifu>()
                    };
                    shop = await WaifuShopDb.AddShop(shop);
                }
                return shop;
            }

            if (overrideNew || shop == null || shop.GeneratedDate.AddHours(12) < DateTime.Now)
            {
                var newShop = await CreateNewShop(guildId, type);
                await WaifuShopDb.DeleteShop(guildId, type);
                await WaifuShopDb.AddShop(newShop);
                if (Program.Development == false)
                    _ = Task.Run(() => NotifyWishlist(newShop.ShopWaifus.Select(x => x.Waifu), guildId));
                return newShop;
            }

            return shop;
        }
コード例 #4
0
ファイル: WaifuShopController.cs プロジェクト: ta1H3n/Namiko
        public async Task <List <WaifuView> > Get([FromRoute] ulong id)
        {
            var res = await WaifuShopDb.GetWaifus(id).ConfigureAwait(false);

            return(res.ToView());
        }
コード例 #5
0
        public async Task ModShopAddWaifu([Remainder] string name)
        {
            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+ ~*")
                                                       .WithFooter($"`{prefix}pro`")
                                                       .Build());

                return;
            }

            var shop = await WaifuUtil.GetShop(Context.Guild.Id, ShopType.Mod);

            var waifus = shop.ShopWaifus.Select(x => x.Waifu);

            var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name), this);

            if (waifu == null)
            {
                return;
            }

            if (waifu.Tier < 1 || waifu.Tier > 3)
            {
                await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User)
                                                       .WithDescription($"*~ You can only add Tier 1-3 waifus ~*")
                                                       .Build());

                return;
            }
            if (shop.ShopWaifus.Count >= 15)
            {
                await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User)
                                                       .WithDescription($"*~ The Mod Shop is limited to 15 waifus. `{prefix}msrw` to remove ~*")
                                                       .Build());

                return;
            }
            if (waifus.Any(x => x.Name.Equals(waifu.Name)))
            {
                await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User)
                                                       .WithDescription($"*~ **{waifu.Name}** is already in the mod shop ~*")
                                                       .Build());

                return;
            }

            await WaifuShopDb.UpdateItem(new ShopWaifu
            {
                Discount  = 0,
                Limited   = -1,
                WaifuShop = shop,
                Waifu     = waifu
            });

            await Context.Channel.SendMessageAsync($"Added **{waifu.Name}** to the Mod Shop", embed : WaifuUtil.WaifuEmbedBuilder(waifu).Build());

            return;
        }