Esempio n. 1
0
        public async Task TopByOctoPoints(int page = 1)
        {
            try
            {
                if (page < 1)
                {
                    await CommandHandeling.ReplyAsync(Context,
                                                      "Boole! Try different page <_<");

                    return;
                }

                var currentGuildUsersId = Context.Guild.Users.Select(user => user.Id);
                var accounts            =
                    UserAccounts.GetFilteredAccounts(acc => currentGuildUsersId.Contains(acc.Id), Context.Guild.Id);

                const int usersPerPage = 9;

                var lastPage = 1 + accounts.Count / (usersPerPage + 1);
                if (page > lastPage)
                {
                    await CommandHandeling.ReplyAsync(Context,
                                                      $"Boole. Last Page is {lastPage}");

                    return;
                }

                var ordered = accounts.OrderByDescending(acc => acc.Points).ToList();

                var embB = new EmbedBuilder()
                           .WithTitle("Top By Octo Points:")
                           .WithFooter(
                    $"Page {page}/{lastPage} ● Say \"topp 2\" to see second page (you can edit previous message)");


                page--;
                for (var j = 0; j < ordered.Count; j++)
                {
                    if (ordered[j].Id == Context.User.Id)
                    {
                        embB.WithDescription(
                            $"**#{j + usersPerPage * page + 1} {Context.User.Username} {ordered[j].Points} OctoPoints**\n**______**");
                    }
                }

                for (var i = 1; i <= usersPerPage && i + usersPerPage * page <= ordered.Count; i++)
                {
                    var account = ordered[i - 1 + usersPerPage * page];
                    var user    = Global.Client.GetUser(account.Id);
                    embB.AddField($"#{i + usersPerPage * page} {user.Username}", $"{account.Points} OctoPoints", true);
                }

                await CommandHandeling.ReplyAsync(Context, embB);
            }
            catch
            {
                //   await ReplyAsync(
                //       "boo... An error just appear >_< \nTry to use this command properly: **topp [page_number]**(Top By Activity)\nAlias: topo");
            }
        }
Esempio n. 2
0
        public async Task TopBySubc(int page = 1)
        {
            try
            {
                if (page < 1)
                {
                    await CommandHandeling.ReplyAsync(Context,
                                                      "Boole! Try different page <_<");

                    return;
                }

                // Get only accounts of this server
                var accounts =
                    UserAccounts.GetFilteredAccounts(
                        acc => Context.Guild.Users.Select(user => user.Id).Contains(acc.Id), Context.Guild.Id);

                const int usersPerPage = 9;

                var lastPage = 1 + accounts.Count / (usersPerPage + 1);
                if (page > lastPage)
                {
                    await CommandHandeling.ReplyAsync(Context,
                                                      $"Boole. Last Page is {lastPage}");

                    return;
                }

                foreach (var t in accounts)
                {
                    if (t.SubedToYou == null)
                    {
                        t.SubedToYou = "0";
                    }
                }

                var ordered = accounts.OrderByDescending(acc =>
                                                         acc.SubedToYou.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Length).ToList();

                var embB = new EmbedBuilder()
                           .WithTitle("Top By Subs Qty:")
                           .WithFooter(
                    $"Page {page}/{lastPage} ● Say \"tops 2\" to see second page (you can edit previous message)");

                page--;
                for (var j = 0; j < ordered.Count; j++)
                {
                    if (ordered[j].Id == Context.User.Id)
                    {
                        var size = ordered[j].SubedToYou.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
                                   .Length;
                        if (size == 1)
                        {
                            size = 0;
                        }
                        embB.WithDescription(
                            $"**#{j + usersPerPage * page + 1} {Context.User.Username} {size} Subscribers**\n**______**");
                    }
                }


                for (var i = 1; i <= usersPerPage && i + usersPerPage * page <= ordered.Count; i++)
                {
                    var account = ordered[i - 1 + usersPerPage * page];
                    var user    = Global.Client.GetUser(account.Id);

                    var size = account.SubedToYou.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Length;
                    if (size == 1)
                    {
                        size = 0;
                    }
                    embB.AddField($"#{i + usersPerPage * page} {user.Username}", $"{size} Subscribers", true);
                }

                await CommandHandeling.ReplyAsync(Context, embB);
            }
            catch
            {
                //   await ReplyAsync(
                //       "boo... An error just appear >_< \nTry to use this command properly: **tops [page_number]**(Top By Subs Qty)");
            }
        }
Esempio n. 3
0
        public async Task TopByRatingArt(int page = 1)
        {
            try
            {
                if (page < 1)
                {
                    await CommandHandeling.ReplyAsync(Context,
                                                      "Boole! Try different page <_<");

                    return;
                }


                var currentGuildUsersId = Context.Guild.Users.Select(user => user.Id);
                // Get only accounts of this server
                var accounts =
                    UserAccounts.GetFilteredAccounts(acc => currentGuildUsersId.Contains(acc.Id), Context.Guild.Id);


                foreach (var t in accounts)
                {
                    if (t.ArtVotesQty <= 0)
                    {
                        t.ArtAvarageScoreVotes = (float)0.0;
                    }
                    else
                    {
                        t.ArtAvarageScoreVotes = (float)t.ArtVotesSum / t.ArtVotesQty;
                    }

                    UserAccounts.SaveAccounts(Context.Guild.Id);
                }

                const int usersPerPage = 9;

                var lastPage = 1 + accounts.Count / (usersPerPage + 1);
                if (page > lastPage)
                {
                    await CommandHandeling.ReplyAsync(Context,
                                                      $"Boole. Last Page is {lastPage}");

                    return;
                }

                var ordered = accounts.OrderByDescending(acc => acc.ArtAvarageScoreVotes).ToList();

                var embB = new EmbedBuilder()
                           .WithTitle("Top By :art: Rating Messages:")
                           .WithFooter(
                    $"Page {page}/{lastPage} ● Say \"topa 2\" to see second page (you can edit previous message)");


                page--;
                for (var j = 0; j < ordered.Count; j++)
                {
                    if (ordered[j].Id == Context.User.Id)
                    {
                        embB.WithDescription(
                            $"**#{j + usersPerPage * page + 1} {Context.User.Username} {Math.Round(ordered[j].ArtAvarageScoreVotes, 2)} out of 5 ({ordered[j].BlogVotesQty} votes)**\n**______**");
                    }
                }

                for (var i = 1; i <= usersPerPage && i + usersPerPage * page <= ordered.Count; i++)
                {
                    var account = ordered[i - 1 + usersPerPage * page];
                    var user    = Global.Client.GetUser(account.Id);
                    embB.AddField($"#{i + usersPerPage * page} {user.Username}",
                                  $"**{Math.Round(account.ArtAvarageScoreVotes, 2)}** out of 5 ({account.ArtVotesQty} votes)",
                                  true);
                }

                await CommandHandeling.ReplyAsync(Context, embB);
            }
            catch
            {
                //   await ReplyAsync(
                //       "boo... An error just appear >_< \nTry to use this command properly: **topa [page_number]**(Top by :art: rating messages)");
            }
        }