public async Task ShowWaifu([Remainder] string name) { var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name), this); if (waifu == null) { //await Context.Channel.SendMessageAsync($"Can't find '{name}'. I know they are not real, but this one *really is* just your imagination >_>"); return; } var eb = WaifuUtil.WaifuEmbedBuilder(waifu, Context); await Context.Channel.SendMessageAsync("", false, eb.Build()); }
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(); }); }
public async Task NewWaifuAutocomplete(string name, long malId, string url = null) { var exists = await WaifuDb.GetWaifu(name); if (exists != null) { await ReplyAsync($"**{exists.Name}** is already a waifu."); return; } await Context.Channel.TriggerTypingAsync(); url ??= Context.Message.Attachments.FirstOrDefault()?.Url; if (url != null) { url = url.EndsWith(".gifv") ? url.Replace(".gifv", ".gif") : url; url = url.EndsWith(".mp4") ? url.Replace(".mp4", ".gif") : url; if (ImgurAPI.RateLimit.ClientRemaining < 15) { await ReplyAsync("Not enough imgur credits to upload. Please try again later."); return; } string albumId; if (!ImageDb.AlbumExists("Waifus")) { albumId = (await ImgurAPI.CreateAlbumAsync("Waifus")).Id; await ImageDb.CreateAlbum("Waifus", albumId); } else { albumId = ImageDb.GetAlbum("Waifus").AlbumId; } var iImage = await ImgurAPI.UploadImageAsync(url, albumId, null, name); url = iImage.Link; } var waifu = new Waifu { Name = name, Tier = 404, ImageUrl = url, Description = null, LongName = null }; await WaifuUtil.UploadWaifuImage(waifu, Context.Channel); var mal = await WebUtil.GetWaifu(malId); waifu.LongName = $"{mal.Name} ({mal.NameKanji})"; var about = mal.About; var lines = about.Split('\n'); string desc = ""; foreach (var line in lines) { if (line.Split(' ')[0].EndsWith(':')) { continue; } if (line.StartsWith('(')) { continue; } var l = Regex.Replace(line, @"\t|\n|\r|\\n|\\t|\\r", ""); if (l != "") { desc += l + "\n\n"; } } waifu.Description = desc; waifu.Source = mal.Animeography.FirstOrDefault() == null ? "" : mal.Animeography.FirstOrDefault().Name; try { waifu.Tier = WaifuUtil.FavoritesToTier(mal.MemberFavorites.Value); } catch { } if (waifu.Tier == 0) { waifu.Tier = 3; await Context.Channel.SendMessageAsync($"Not enough favorites! Are you sure you wish to create this waifu? Remove - `!dw {waifu.Name}`"); } if (await WaifuDb.AddWaifu(waifu) > 0) { await Context.Channel.SendMessageAsync ( $"Autocompleted **{waifu.Name}**. Has **{mal.MemberFavorites}** favorites.", embed : WaifuUtil.WaifuEmbedBuilder(waifu, Context).Build() ); await WaifuDb.AddMalWaifu(new MalWaifu { MalId = malId, WaifuName = waifu.Name, LastUpdated = DateTime.Now, MalConfirmed = true }); } else { await Context.Channel.SendMessageAsync("Rip"); } await Context.Channel.TriggerTypingAsync(); await WaifuUtil.FindAndUpdateWaifuImageSource(waifu, Context.Channel); }
public async Task AutocompleteWaifu(string name, long malId) { var waifu = await WaifuDb.GetWaifu(name); if (waifu == null) { await Context.Channel.SendMessageAsync($"**{name}** doesn't exist. *BAAAAAAAAAAAAAAAAAAKA*"); return; } var mal = await WebUtil.GetWaifu(malId); waifu.LongName = $"{mal.Name} ({mal.NameKanji})"; var about = mal.About; var lines = about.Split('\n'); string desc = ""; foreach (var line in lines) { if (line.Split(' ')[0].EndsWith(':')) { continue; } if (line.StartsWith('(')) { continue; } var l = Regex.Replace(line, @"\t|\n|\r|\\n|\\t|\\r", ""); if (l != "") { desc += l + "\n\n"; } } //desc.Replace(@"\r", @"\n\n"); waifu.Description = desc; waifu.Source = mal.Animeography.FirstOrDefault() == null ? "" : mal.Animeography.FirstOrDefault().Name; await WaifuDb.UpdateWaifu(waifu); await Context.Channel.SendMessageAsync($"Autocompleted **{waifu.Name}**. Has **{mal.MemberFavorites}** favorites.", false, WaifuUtil.WaifuEmbedBuilder(waifu, Context).Build()); }
public async Task ShipWaifu(IUser user, [Remainder] string name) { var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name), this); if (waifu == null) { return; } if (waifu.Tier < 1 || waifu.Tier > 3) { if (!(Context.Guild.Id == 738291903770132646 && waifu.Tier == 825)) { await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User) .WithDescription($"*~ You can only ship Tier 1-3 waifus ~*") .Build()); return; } } if (UserInventoryDb.OwnsWaifu(user.Id, waifu, Context.Guild.Id)) { await Context.Channel.SendMessageAsync($"They already own **{waifu.Name}**"); return; } await UserInventoryDb.AddWaifu(user.Id, waifu, Context.Guild.Id); await Context.Channel.SendMessageAsync($"**{waifu.Name}** shipped!", embed : WaifuUtil.WaifuEmbedBuilder(waifu).Build()); }
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; }
public async Task GiveWaifu(IUser recipient, [Remainder] string str = "") { var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(str, false, UserInventoryDb.GetWaifus(Context.User.Id, Context.Guild.Id)), 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($"**{waifu.Name}** is just like my love - you don't have it."); return; } waifus = UserInventoryDb.GetWaifus(recipient.Id, Context.Guild.Id); if (waifus.Any(x => x.Name.Equals(waifu.Name))) { await Context.Channel.SendMessageAsync($"They already have **{waifu.Name}**."); return; } await UserInventoryDb.AddWaifu(recipient.Id, waifu, Context.Guild.Id); await UserInventoryDb.DeleteWaifu(Context.User.Id, waifu, Context.Guild.Id); await Context.Channel.SendMessageAsync($"{recipient.Mention} You received **{waifu.Name}** from {Context.User.Mention}!", false, WaifuUtil.WaifuEmbedBuilder(waifu).Build()); }
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 static async Task Timer_RequestSauce(object sender, ElapsedEventArgs e) { Waifu waifu = null; List <Embed> embeds = new List <Embed>(); SauceRequest req = null; if (sender != null && sender is SauceRequest) { req = sender as SauceRequest; waifu = req.Waifu; } try { using var db = new NamikoDbContext(); if (waifu != null) { waifu = await db.Waifus.AsQueryable().FirstOrDefaultAsync(x => x.Source.Equals(waifu.Source) && x.ImageSource.Equals("missing")); } if (waifu == null) { waifu = await db.Waifus.AsQueryable().OrderBy(x => Guid.NewGuid()).FirstOrDefaultAsync(x => x.ImageSource.Equals("missing")); if (waifu == null) { await WebhookClients.SauceRequestChannel.SendMessageAsync("`No unknown sauces. Idling...`"); return; } } embeds.Add(WaifuUtil.WaifuEmbedBuilder(waifu).Build()); var res = await WebUtil.SauceNETSearchAsync(waifu.HostImageUrl); if (res.Message.Contains("limit exceeded", StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("Sauce limit exceeded"); } else { embeds.Add(WebUtil.SauceEmbed(res, waifu.HostImageUrl).Build()); } var family = await db.Waifus.AsQueryable().Where(x => x.Source.Equals(waifu.Source) && !(x.ImageSource == null || x.ImageSource.Equals("retry") || x.ImageSource.Equals("missing"))).ToListAsync(); family = family.DistinctBy(x => x.ImageSource).ToList(); string familySauces = ""; foreach (var w in family) { string add = $"**{w.Name}** - {w.ImageSource}\n"; if ((familySauces + add).Length < 1900) { familySauces += add; } } if (familySauces != "") { var eb = new EmbedBuilderPrepared(); eb.WithTitle("Possible sauces"); eb.WithDescription($"Image sauces of waifus from **{waifu.Source}**:\n{familySauces}"); embeds.Add(eb.Build()); } if (req == null || req.Channel == null) { await WebhookClients.SauceRequestChannel.SendMessageAsync("Missing waifu image sauce", embeds : embeds); } else { foreach (var embed in embeds) { await req.Channel.SendMessageAsync(embed : embed); } } } catch (Exception ex) { SentrySdk.WithScope(scope => { if (waifu != null) { scope.SetExtras(waifu.GetProperties()); } SentrySdk.CaptureException(ex); }); if (req == null || req.Channel == null) { await WebhookClients.SauceRequestChannel.SendMessageAsync($"Broke on **{waifu.Name}** - please find source manually."); } else { await req.Channel.SendMessageAsync($"Broke on **{waifu.Name}** - please find source manually."); } } }