public static async Task<WaifuShop> CreateNewShop(ulong guildId, ShopType type) { var date = System.DateTime.Now.Date; if (DateTime.Now.Hour >= 12) date = date.AddHours(12); WaifuShop shop = new WaifuShop { GeneratedDate = date, GuildId = guildId, Type = type }; List<ShopWaifu> waifus = null; switch (type) { case ShopType.Waifu: waifus = await GenerateWaifuShopList(guildId); break; case ShopType.Gacha: waifus = await GenerateGachaShopList(guildId); break; default: return null; } shop.ShopWaifus = waifus; return shop; }
public async Task ModShop([Remainder] string str = "") { WaifuShop shop = await WaifuUtil.GetShop(Context.Guild.Id, ShopType.Mod); int count = Constants.shoplimitedamount + Constants.shopt1amount + Constants.shopt2amount + Constants.shopt3amount; string prefix = Program.GetPrefix(Context); List <ShopWaifu> waifus = new List <ShopWaifu>(); if (shop != null) { waifus = shop.ShopWaifus; } waifus = waifus.OrderBy(x => x.Waifu.Tier).ThenBy(x => x.Waifu.Source).ThenBy(x => x.Waifu.Name).ToList(); if (waifus.Count <= count) { var eb = WaifuUtil.NewShopEmbed(waifus, prefix, Context.Guild.Id, ShopType.Mod); await Context.Channel.SendMessageAsync("", false, eb.Build()); return; } await PagedReplyAsync(WaifuUtil.PaginatedShopMessage(waifus, count, prefix, Context.Guild.Id, ShopType.Mod)); }
public async Task GachaShop([Remainder] string str = "") { WaifuShop shop = await WaifuUtil.GetShop(Context.Guild.Id, ShopType.Gacha); string prefix = Program.GetPrefix(Context); var waifus = shop.ShopWaifus.OrderByDescending(x => x.Limited).ThenBy(x => x.Waifu.Tier).ThenBy(x => x.Waifu.Source).ToList(); var eb = WaifuUtil.NewShopEmbed(waifus, prefix, Context.Guild.Id, ShopType.Gacha); await Context.Channel.SendMessageAsync("", false, eb.Build()); }
// 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; }
public static WaifuShop OrderWaifuShop(this WaifuShop shop) { shop.ShopWaifus = OrderWaifuShop(shop.ShopWaifus, shop.Type); return shop; }