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); } }
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; }