Exemplo n.º 1
0
        public async Task ScrapeDatabase() //Scrapes the entire bot database and creates accounts for every single member of every single guild the bot is in.
        {
            stopWatch.Start();
            var _client = Global.Client;
            var servers = Servers.GetAllServers();

            embed.WithDescription($"**{Context.User.Mention} Scraping...**");
            embed.WithColor(Red);
            await BE();

            foreach (var server in servers)
            {
                var   isolatedServer   = Servers.GetServer(server.ID);
                ulong isolatedServerID = isolatedServer.ID;
                var   guild            = _client.GetGuild(isolatedServerID);
                if (guild != null)
                {
                    if (guild.MemberCount > 3500)
                    {
                        continue;
                    }                                //If the guild has more than 3500 members, don't create accounts for everyone.
                    var guildUsers = guild.Users;
                    foreach (var user in guildUsers) //Creates account for the user, logging name, ID, and what servers they share with Kaguya.
                    {
                        if (user.IsBot)
                        {
                            continue;
                        }
                        var userAccount = UserAccounts.GetAccount(user);
                        userAccount.Username = user.Username + "#" + user.Discriminator;
                        userAccount.ID       = user.Id;

                        if (!userAccount.IsInServerIDs.Contains(guild.Id))
                        {
                            userAccount.IsInServerIDs.Add(guild.Id);
                        }
                        if (!userAccount.IsInServers.Contains(guild.Name))
                        {
                            userAccount.IsInServers.Add(guild.Name);
                        }
                    }
                }
            }
            UserAccounts.SaveAccounts();
            embed.WithDescription($"**{Context.User.Mention} Created accounts for `{UserAccounts.GetAllAccounts().Count}` users.**");
            embed.WithColor(Red);
            await BE();

            stopWatch.Stop();
            logger.ConsoleCommandLog(Context, stopWatch.ElapsedMilliseconds, $"Database scraped: {UserAccounts.GetAllAccounts().Count} users affected.");
        }
Exemplo n.º 2
0
        public async Task Activity()
        {
            var acc = UserAccounts.GetAllAccounts();

            await ReplyAsync("", false, new EmbedBuilder()
                             .WithDescription("Server activity")
                             .AddField("Total Members", acc.Count(), true)
                             .AddField("24h", acc.Count(a => DateTime.Now.Subtract(new TimeSpan(24, 0, 0)) < a.ServerStats.LastDayActive), true)
                             .AddField("3 Days", acc.Count(a => DateTime.Now.Subtract(new TimeSpan(3, 0, 0, 0)) < a.ServerStats.LastDayActive), true)
                             .AddField("7 Days", acc.Count(a => DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0)) < a.ServerStats.LastDayActive), true)
                             .AddField("30 Days", acc.Count(a => DateTime.Now.Subtract(new TimeSpan(30, 0, 0, 0)) < a.ServerStats.LastDayActive), true)
                             .AddField("All Time", acc.Count(a => DateTime.Now > DateTime.MinValue), true)
                             .Build());
        }
Exemplo n.º 3
0
        public async Task TimelyReset()
        {
            var commands = Commands.GetCommand();
            var accounts = UserAccounts.GetAllAccounts();

            foreach (var account in accounts)
            {
                var difference = DateTime.Now.AddHours(-24);
                account.LastReceivedTimelyPoints = difference;
            }
            embed.WithTitle("Timely Reset");
            embed.WithDescription($"**{Context.User.Mention} Timely points for `{accounts.Count}` users have been reset!**");
            embed.WithColor(Pink);
            BE();
        }
Exemplo n.º 4
0
        public async Task TimelyReset()
        {
            stopWatch.Start();
            var accounts = UserAccounts.GetAllAccounts();

            foreach (var account in accounts)
            {
                var difference = DateTime.Now.AddHours(-24);
                account.LastReceivedTimelyPoints = difference;
            }
            embed.WithTitle("Timely Reset");
            embed.WithDescription($"**{Context.User.Mention} Timely points for `{accounts.Count}` users have been reset!**");
            embed.WithColor(Pink);
            await BE(); stopWatch.Stop();
            logger.ConsoleCommandLog(Context, stopWatch.ElapsedMilliseconds);
        }
Exemplo n.º 5
0
        public async Task AwardEveryone(int bonus)
        {
            var userAccounts = UserAccounts.GetAllAccounts();
            int i            = 1;

            foreach (UserAccount account in userAccounts)
            {
                i++;
                account.Points = (uint)(account.Points + bonus);
            }
            UserAccounts.SaveAccounts();
            embed.WithTitle("Points Awarded");
            embed.WithDescription($"{Context.User.Mention} has awarded `{bonus.ToString("N0")}` points to `{i.ToString("N0")}` users!");
            embed.WithColor(Gold);
            BE();
        }
Exemplo n.º 6
0
        public async Task GlobalEXPLeaderboard()
        {
            var users = UserAccounts.GetAllAccounts();

            UserAccounts.SaveAccounts();
            var users10 = users.OrderByDescending(u => u.EXP).Take(10);

            embed.WithTitle("Kaguya Global EXP Leaderboard");
            int i = 1;

            foreach (var user in users10)
            {
                embed.AddField($"#{i++} {user.Username}", $"Level: {user.LevelNumber} - EXP: {user.EXP}");
            }
            embed.WithColor(Pink);
            BE();
        }
Exemplo n.º 7
0
        public async Task AwardEveryone(int bonus)
        {
            stopWatch.Start();
            var userAccounts = UserAccounts.GetAllAccounts();
            int i            = 1;

            foreach (UserAccount account in userAccounts)
            {
                i++;
                account.Points = (uint)(account.Points + bonus);
            }
            UserAccounts.SaveAccounts();
            embed.WithTitle("Points Awarded");
            embed.WithDescription($"{Context.User.Mention} has awarded `{bonus.ToString("N0")}` points to `{i.ToString("N0")}` users!");
            embed.WithColor(Gold);
            await BE(); stopWatch.Stop();
            logger.ConsoleCommandLog(Context, stopWatch.ElapsedMilliseconds);
        }
Exemplo n.º 8
0
        public async Task GlobalEXPLeaderboard()
        {
            stopWatch.Start();
            var users = UserAccounts.GetAllAccounts();

            UserAccounts.SaveAccounts();
            var users10 = users.OrderByDescending(u => u.EXP).Take(10);

            embed.WithTitle("Kaguya Global EXP Leaderboard");
            int i = 1;

            foreach (var user in users10)
            {
                embed.AddField($"#{i++} {user.Username}", $"Level: {user.LevelNumber} - EXP: {user.EXP}");
            }
            embed.WithColor(Pink);
            await BE(); stopWatch.Stop();
            logger.ConsoleCommandLog(Context, stopWatch.ElapsedMilliseconds);
        }