public async Task WaifuImageSource([Remainder] string name) { var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name, true, null, true), this); if (waifu == null) { return; } string str = "```yaml\n"; str += $"Name: {waifu.Name}\n"; str += $"FullName: {waifu.LongName}\n"; str += $"Source: {waifu.Source}\n"; str += $"Description: {waifu.Description}\n"; str += $"ImgurUrl: {waifu.ImageUrl}\n"; str += $"NamikoMoeUrl: {waifu.HostImageUrl}\n"; str += $"ImageSource: {waifu.ImageSource}\n"; str += $"Tier: {waifu.Tier}\n"; str += $"MalId: {waifu.Mal?.MalId}\n"; str += "```"; await Context.Channel.SendMessageAsync(str); }
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 WaifuWishlist([Remainder] IUser user = null) { user ??= Context.User; var waifus = await WaifuWishlistDb.GetWishlist(user.Id, Context.Guild.Id); await Context.Channel.SendMessageAsync(null, false, WaifuUtil.WishlistEmbed(waifus, (SocketGuildUser)user).Build()); }
public async Task WaifuMal(string name, long malId) { var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name, true, includeMAL: true), this); if (waifu == null) { return; } var mal = waifu.Mal ?? new MalWaifu { WaifuName = waifu.Name }; mal.LastUpdated = DateTime.Now; mal.MalConfirmed = true; mal.MalId = malId; if ((await WaifuDb.UpdateMalWaifu(mal)) > 0) { await Context.Channel.SendMessageAsync($":white_check_mark: {waifu.Name} updated."); } else { await Context.Channel.SendMessageAsync($":x: Failed to update {name}"); } }
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 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 ShipWaifu(string name, ulong userId, ulong guildId = 0) { Program.GetPrefix(Context); if (guildId == 0) { guildId = Context.Guild.Id; } var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name), this); if (waifu == null) { return; } if (UserInventoryDb.OwnsWaifu(userId, waifu, guildId)) { await Context.Channel.SendMessageAsync($"They already own **{waifu.Name}**"); return; } await UserInventoryDb.AddWaifu(userId, waifu, guildId); await Context.Channel.SendMessageAsync($"**{waifu.Name}** shipped!"); }
public async Task ResetWaifuShop() { await WaifuUtil.GetShop(Context.Guild.Id, ShopType.Waifu, true); await WaifuUtil.GetShop(Context.Guild.Id, ShopType.Gacha, true); await Context.Channel.SendMessageAsync("Waifu Shop and Gacha Shop reset."); }
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; }
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()); }
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 WishWaifu([Remainder] string str = "") { var user = Context.User; Waifu waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(str), this); if (waifu == null) { return; } var waifus = await WaifuWishlistDb.GetWishlist(user.Id, Context.Guild.Id); int cap = 5; if (PremiumDb.IsPremium(Context.User.Id, ProType.ProPlus)) { cap = 12; } string prefix = Program.GetPrefix(Context); if (waifus.Count >= cap) { await Context.Channel.SendMessageAsync(embed : new EmbedBuilderPrepared(Context.User) .WithDescription($"You have reached your wishlist limit of **{cap}**.\n" + $"Try `{prefix}rww` to remove a waifu.") .WithFooter($"Increase the limit: `{prefix}pro`") .Build()); return; } if (waifus.Any(x => x.Name == waifu.Name)) { await Context.Channel.SendMessageAsync($"**{waifu.Name}** is already in your wishlist. Baka."); return; } if (UserInventoryDb.OwnsWaifu(user.Id, waifu, Context.Guild.Id)) { await Context.Channel.SendMessageAsync($"You already own **{waifu.Name}**. Baka."); return; } await WaifuWishlistDb.AddWaifuWish(Context.User.Id, waifu, Context.Guild.Id); waifus = await WaifuWishlistDb.GetWishlist(user.Id, Context.Guild.Id); await Context.Channel.SendMessageAsync($"Added **{waifu.Name}** to your wishlist!", false, WaifuUtil.WishlistEmbed(waifus, (SocketGuildUser)user).Build()); }
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 static EmbedBuilder TeamEmbed(SocketRole teamRole, SocketRole leaderRole) { var eb = new EmbedBuilder(); List <SocketGuildUser> leaderUsers = new List <SocketGuildUser>(leaderRole.Members); List <SocketGuildUser> teamUsers = new List <SocketGuildUser>(teamRole.Members); teamUsers.RemoveAll(x => leaderUsers.Any(y => y.Equals(x))); int totalToasties = 0; int totalWaifus = 0; int totalWaifuValue = 0; string memberList = ""; foreach (var x in teamUsers) { memberList += $"\n`{x.Username}`"; totalToasties += BalanceDb.GetToasties(x.Id, x.Guild.Id); var waifus = UserInventoryDb.GetWaifus(x.Id, x.Guild.Id); totalWaifus += waifus.Count; totalWaifuValue += WaifuUtil.WaifuValue(waifus); } string leaderList = ""; foreach (var x in leaderUsers) { leaderList += $"\n`{x.Username}`"; totalToasties += BalanceDb.GetToasties(x.Id, x.Guild.Id); var waifus = UserInventoryDb.GetWaifus(x.Id, x.Guild.Id); totalWaifus += waifus.Count; totalWaifuValue += WaifuUtil.WaifuValue(waifus); } eb.WithDescription($"Total Toasties: {totalToasties.ToString("n0")} <:toastie3:454441133876183060>\n" + $"Total Waifus: {totalWaifus.ToString("n0")} :two_hearts:\n" + $"Waifu Value: {totalWaifuValue.ToString("n0")} <:toastie3:454441133876183060>"); eb.AddField($":shield: Members - {teamUsers.Count}", memberList == "" ? "-" : memberList, true); eb.AddField($":crown: Leaders - {leaderUsers.Count}", leaderList == "" ? "-" : leaderList, true); eb.WithColor(BasicUtil.RandomColor()); eb.WithTitle(teamRole.Name); return(eb); }
public static CustomPaginatedMessage PaginatedShopMessage(IEnumerable<ShopWaifu> waifus, int pageSize, string prefix, ulong guildId = 0, ShopType type = ShopType.Waifu) { CustomPaginatedMessage paginatedMessage = new CustomPaginatedMessage(); var fieldList = new List<FieldPages>(); var splitWaifus = CustomPaginatedMessage.Split(waifus, pageSize); int pages = splitWaifus.Count(); var fieldInfo = new FieldPages(); var pagelist = new List<string>(); fieldInfo.Title = ":books: Commands"; for (int i = 0; i < pages; i++) { pagelist.Add($"`{prefix}BuyWaifu [name]` | `{prefix}Waifu [search]` | `{prefix}Ws` | `{prefix}Gs` | `{prefix}Ms`"); } fieldInfo.Inline = true; fieldInfo.Pages = pagelist; fieldList.Add(fieldInfo); var fieldWaifus = new FieldPages(); var pagelist2 = new List<string>(); fieldWaifus.Title = "<:MiaHug:536580304018735135> Waifus"; foreach (var w in splitWaifus) { pagelist2.Add(WaifuUtil.WaifuShopWaifuList(w)); } fieldWaifus.Pages = pagelist2; fieldList.Add(fieldWaifus); paginatedMessage.Fields = fieldList; paginatedMessage.Footer = $"Resets in {11 - DateTime.Now.Hour % 12} Hours {60 - DateTime.Now.Minute} Minutes | "; paginatedMessage.Color = BasicUtil.RandomColor(); paginatedMessage.PageCount = pages; if (guildId != 0) paginatedMessage.Pages = new List<string> { $"Open in [browser](https://namiko.moe/WaifuShop/{guildId})" }; paginatedMessage.Author = new EmbedAuthorBuilder() { Name = type switch { ShopType.Waifu => "Waifu Shop", ShopType.Gacha => "Gacha Shop", ShopType.Mod => "Mod Shop", _ => "Waifu Shop" },
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; }
public async Task WaifuShopSlides([Remainder] string str = "") { List <ShopWaifu> waifus = (await WaifuUtil.GetShop(Context.Guild.Id, ShopType.Waifu)).ShopWaifus; waifus.RemoveAt(0); var lockObj = new Object(); if (slideLock.ContainsKey(Context.Channel.Id)) { slideLock.Remove(Context.Channel.Id); } slideLock.Add(Context.Channel.Id, lockObj); var eb = WaifuUtil.WaifuShopSlideEmbed(waifus[0].Waifu); var msg = await Context.Channel.SendMessageAsync("", false, eb.Build()); await Task.Delay(5000); for (int i = 1; i < waifus.Count; i++) { if (slideLock.GetValueOrDefault(Context.Channel.Id) != lockObj) { break; } eb = WaifuUtil.WaifuShopSlideEmbed(waifus[i].Waifu); await msg.ModifyAsync(x => x.Embed = eb.Build()); await Task.Delay(5000); } eb = WaifuUtil.WaifuShopSlideEmbed(waifus[new Random().Next(waifus.Count)].Waifu); eb.WithFooter("Slideshow ended."); await msg.ModifyAsync(x => x.Embed = eb.Build()); if (slideLock.GetValueOrDefault(Context.Channel.Id) == lockObj) { slideLock.Remove(Context.Channel.Id); } }
public async Task RemoveWaifuWish([Remainder] string str = "") { var user = Context.User; Waifu waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(str, false, await WaifuWishlistDb.GetWishlist(Context.User.Id, Context.Guild.Id)), this); if (waifu == null) { return; } var waifus = await WaifuWishlistDb.GetWishlist(user.Id, Context.Guild.Id); if (!waifus.Any(x => x.Name == waifu.Name)) { await Context.Channel.SendMessageAsync($"**{waifu.Name}** is not in your wishlist. Baka."); return; } await WaifuWishlistDb.DeleteWaifuWish(user.Id, waifu, Context.Guild.Id); await Context.Channel.SendMessageAsync("You don't want her anymore, huh..."); }
public async Task WaifuTier(string name, int tier) { var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name, true), this); if (waifu == null) { return; } string old = waifu.Tier.ToString(); waifu.Tier = tier; if (await WaifuDb.UpdateWaifu(waifu) > 0) { await SendWaifuUpdatedMessage(waifu, "Tier", old, waifu.Tier.ToString()); } else { await Context.Channel.SendMessageAsync($":x: Failed to update {name}"); } }
public async Task WaifuSource(string name, [Remainder] string source = null) { var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name, true), this); if (waifu == null) { return; } string old = waifu.Source; waifu.Source = source; if (await WaifuDb.UpdateWaifu(waifu) > 0) { await SendWaifuUpdatedMessage(waifu, "Source", old, waifu.Source); } else { await Context.Channel.SendMessageAsync($":x: Failed to update {name}"); } }
public async Task WaifuLeaderboard([Remainder] string str = "") { var AllWaifus = await UserInventoryDb.GetAllWaifuItems(Context.Guild.Id); var users = new Dictionary <SocketUser, int>(); foreach (var x in AllWaifus) { var user = Context.Guild.GetUser(x.UserId); if (user != null) { if (!users.ContainsKey(user)) { users.Add(user, WaifuUtil.WaifuValue(AllWaifus.Where(x => x.UserId == user.Id).Select(x => x.Waifu))); } } } var ordUsers = users.OrderByDescending(x => x.Value); var msg = new CustomPaginatedMessage(); msg.Title = "User Leaderboards"; var fields = new List <FieldPages> { new FieldPages { Title = "Waifu Value <:toastie3:454441133876183060>", Pages = CustomPaginatedMessage.PagesArray(ordUsers, 10, (x) => $"{x.Key.Mention} - {x.Value}\n") } }; msg.Fields = fields; await PagedReplyAsync(msg); }
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."); } } }
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(); }); }
// Embeds //Embed Method: profile public static async Task <EmbedBuilder> ProfileEmbed(SocketGuildUser user) { var eb = new EmbedBuilder(); string name = user.Username; var role = RoleUtil.GetMemberRole(user.Guild, user) ?? RoleUtil.GetLeaderRole(user.Guild, user); if (role != null) { var team = TeamDb.TeamByMember(role.Id) ?? TeamDb.TeamByLeader(role.Id); if (team != null) { role = user.Roles.FirstOrDefault(x => x.Id == team.LeaderRoleId); if (role == null) { role = user.Roles.FirstOrDefault(x => x.Id == team.MemberRoleId); } name += $" | {role.Name}"; } } if (PremiumDb.IsPremium(user.Id, ProType.ProPlus)) { name += " | Pro+ 🌟"; } else if (PremiumDb.IsPremium(user.Id, ProType.Pro)) { name += " | Pro ⭐"; } eb.WithAuthor(name, user.GetAvatarUrl(), $"https://namiko.moe/Guild/{user.Guild.Id}/{user.Id}"); var waifus = UserInventoryDb.GetWaifus(user.Id, user.Guild.Id); int waifucount = waifus.Count(); int waifuprice = WaifuUtil.WaifuValue(waifus); var daily = DailyDb.GetDaily(user.Id, user.Guild.Id); long timeNow = DateTimeOffset.Now.ToUnixTimeMilliseconds(); string text = ""; text += $"Amount: {BalanceDb.GetToasties(user.Id, user.Guild.Id).ToString("n0")}\n" + $"Daily: {(daily == null ? "0" : ((daily.Date + 172800000) < timeNow ? "0" : daily.Streak.ToString()))}\n" + $"Boxes Opened: {ProfileDb.GetLootboxOpenedAmount(user.Id)}\n"; eb.AddField("Toasties <:toastie3:454441133876183060>", text, true); text = $"Amount: {waifucount}\n" + $"Value: {waifuprice.ToString("n0")}\n"; foreach (var x in MarriageDb.GetMarriages(user.Id, user.Guild.Id)) { try { if (!text.Contains("Married: ")) { text += "Married: "; } text += $"{BasicUtil.IdToMention(GetWifeId(x, user.Id))}\n"; } catch { } } eb.AddField("Waifus :two_hearts:", text, true); var waifu = FeaturedWaifuDb.GetFeaturedWaifu(user.Id, user.Guild.Id); if (waifu != null) { eb.WithImageUrl(waifu.HostImageUrl); eb.AddField("Featured Waifu <:MiaHug:536580304018735135>", $"**{waifu.Name}** - *{waifu.Source}*"); } var rep = ProfileDb.GetRepAmount(user.Id); string footer = $"Votes: {await VoteDb.VoteCount(user.Id)} • "; footer += $"Rep: {rep} • "; // Activities require guildpresence //footer += $"Status: '{user.Status}'"; //var activity = user.Activities.FirstOrDefault(); //if (activity != null) // footer += $", {activity.Type}: '{activity.Name}'"; eb.WithFooter(footer); //quote string quote = ProfileDb.GetQuote(user.Id); if (!String.IsNullOrEmpty(quote) & !WebUtil.IsValidUrl(quote)) { eb.WithDescription(quote); } //image string image = ProfileDb.GetImage(user.Id); if (WebUtil.IsValidUrl(image)) { eb.WithThumbnailUrl(image); } eb.Color = ProfileDb.GetHex(out string colour, user.Id)? (Discord.Color)HexToColor(colour) : BasicUtil.RandomColor(); return(eb); }
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 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 WaifuImage(string name, string url = null) { var waifu = await WaifuUtil.ProcessWaifuListAndRespond(await WaifuDb.SearchWaifus(name, true), this); if (waifu == null) { return; } await Context.Channel.TriggerTypingAsync(); url ??= Context.Message.Attachments.FirstOrDefault()?.Url; if (url == null) { await Context.Channel.SendMessageAsync("Can't get your attachment, there probably isn't one. *Heh, dummy...*"); return; } 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); string old = waifu.ImageUrl; waifu.ImageUrl = iImage.Link; await WaifuUtil.UploadWaifuImage(waifu, Context.Channel); if (await WaifuDb.UpdateWaifu(waifu) > 0) { await SendWaifuUpdatedMessage(waifu, "ImageUrl", old, waifu.ImageUrl); } else { await Context.Channel.SendMessageAsync($":x: Failed to update {name}"); } await Context.Channel.TriggerTypingAsync(); await WaifuUtil.FindAndUpdateWaifuImageSource(waifu, Context.Channel); }
public async Task NewWaifu(string name, int tier, 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 = tier, ImageUrl = url, Description = null, LongName = null }; await WaifuUtil.UploadWaifuImage(waifu, Context.Channel); if (await WaifuDb.AddWaifu(waifu) > 0) { await Context.Channel.SendMessageAsync($"{name} added."); } else { await Context.Channel.SendMessageAsync($"Failed to add {name}"); } await Context.Channel.TriggerTypingAsync(); await WaifuUtil.FindAndUpdateWaifuImageSource(waifu, Context.Channel); }
public static async Task <EmbedBuilder> ServerInfo(SocketGuild guild) { var eb = new EmbedBuilder(); string name = guild.Name; if (PremiumDb.IsPremium(guild.Id, ProType.GuildPlus)) { name += " | T1 Guild 🌟"; } else if (PremiumDb.IsPremium(guild.Id, ProType.Guild)) { name += " | T2 Guild ⭐"; } eb.WithAuthor(name, guild.IconUrl, LinkHelper.GetRedirectUrl(LinkHelper.Patreon, "Patreon", "cmd-embed-info")); var toasties = (await BalanceDb.GetAllToastiesRaw(guild.Id)).OrderByDescending(x => x.Amount).ToList(); var waifus = await UserInventoryDb.GetAllWaifuItems(guild.Id); string field = ""; field += $"Total toasties: **{toasties.Sum(x => (long)x.Amount).ToString("n0")}**\n"; SocketGuildUser user = null; int i = 0; while (i < toasties.Count && (user == null || user.IsBot)) { user = guild.GetUser(toasties[i++].UserId); } if (user != null) { field += $"Richest user: {user.Mention} - **{toasties.FirstOrDefault(x => x.UserId == user.Id).Amount.ToString("n0")}**\n"; } var bank = toasties.FirstOrDefault(x => x.UserId == Program.GetClient().CurrentUser.Id); field += $"Bank balance: **{(bank == null ? "0" : bank.Amount.ToString("n0"))}**\n"; eb.AddField("Toasties <:toastie3:454441133876183060>", field); field = ""; field += $"Total waifus: **{waifus.Count.ToString("n0")}**\n"; field += $"Total waifu value: **{waifus.Sum(x => Convert.ToInt64(WaifuUtil.GetPrice(x.Waifu.Tier, 0))).ToString("n0")}**\n"; var groupedwaifus = waifus.GroupBy(x => x.UserId).OrderByDescending(x => x.Count()).ToList(); IGrouping <ulong, UserInventory> most = null; user = null; i = 0; while (i < groupedwaifus.Count && (user == null || user.IsBot)) { most = groupedwaifus[i]; user = guild.GetUser(groupedwaifus[i++].Key); } if (most != null && user != null) { field += $"Most waifus: {user.Mention} - **{most.Count().ToString("n0")}**\n"; } groupedwaifus = groupedwaifus.OrderByDescending(x => x.Sum(y => WaifuUtil.GetPrice(y.Waifu.Tier, 0))).ToList(); most = null; user = null; i = 0; while (i < groupedwaifus.Count && (user == null || user.IsBot)) { most = groupedwaifus[i]; user = guild.GetUser(groupedwaifus[i++].Key); } if (most != null && user != null) { field += $"Highest value: {user.Mention} - **{most.Sum(y => WaifuUtil.GetPrice(y.Waifu.Tier, 0)).ToString("n0")}**\n"; } eb.AddField("Waifus :two_hearts:", field); eb.WithColor(BasicUtil.RandomColor()); eb.WithFooter("To be expanded"); eb.WithThumbnailUrl(guild.IconUrl); return(eb); }