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