예제 #1
0
        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);
        }
예제 #2
0
        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);
        }