예제 #1
0
        public static async Task HandleContest(SocketMessage message)
        {
            if (message.ToString() == "!d bump")
            {
                BumpGameUser[] lastBumpGameUsers = SecurityFunctions.GetLastBumps();
                DateTime       bumpTime          = DateTime.UtcNow;

                if ((bumpTime - lastBumpGameUsers[0].LastBump).TotalHours >= 2.0)
                {
                    if (SecurityFunctions.GetUser(message.Author.Id) != null)
                    {
                        if (lastBumpGameUsers[0].ID == (long)message.Author.Id && lastBumpGameUsers[1].ID == (long)message.Author.Id && lastBumpGameUsers[2].ID != (long)message.Author.Id)
                        {
                            SecurityFunctions.AddPoints(message.Author.Id, bumpTime, 5);
                        }
                        else
                        {
                            SecurityFunctions.AddPoints(message.Author.Id, bumpTime, 1);
                        }
                    }
                    else
                    {
                        BumpGameUser newUser = new BumpGameUser()
                        {
                            ID = (long)message.Author.Id, Name = message.Author.Username, FirstBump = bumpTime, LastBump = bumpTime, Points = 1
                        };
                        SecurityFunctions.AddUser(newUser);
                    }
                    SecurityFunctions.AddBump(message.Author.Id, bumpTime);
                }
            }
        }
예제 #2
0
        public async Task SetupBotGame()
        {
            Thread.Sleep(10000);
            Random random = new Random();

            while (true)
            {
                int randomNumber = random.Next(0, 4);

                switch (randomNumber)
                {
                case 0:
                    await client.SetGameAsync($"over {client.GetGuild(509544906335715349).Users.Count} lounge guests!", null, ActivityType.Watching);

                    break;

                case 1:
                    BumpGameUser[] users = SecurityFunctions.GetLastBumps();
                    await client.SetGameAsync($"The bumping game. Last game won by: {users[0].Name}.", null, ActivityType.Watching);

                    break;

                case 2:
                    await client.SetGameAsync($"My latency is: {client.Latency} ms.", null, ActivityType.Watching);

                    break;

                case 3:
                    await client.SetGameAsync($"Invite more people!");

                    break;

                case 4:
                    await client.SetGameAsync("Tcl Help", null, ActivityType.Listening);

                    break;
                }
                Thread.Sleep(30000);
            }
        }
예제 #3
0
        public async Task BumpStats()
        {
            int    userPosition    = 1;
            string userStatistics1 = String.Empty;
            string userStatistics2 = String.Empty;
            string nextBumpString  = String.Empty;

            BumpGameUser[] bumpGameUsers        = SecurityFunctions.GetTopUsers(10);
            BumpGameUser[] lastBumpers          = SecurityFunctions.GetLastBumps();
            int            minutesUntilNextBump = 120;

            if (lastBumpers[0].FirstBump.AddHours(2f).Subtract(DateTime.UtcNow).TotalMinutes < 0)
            {
                minutesUntilNextBump = 0;
            }
            else if (lastBumpers[0].FirstBump.AddHours(2f).Subtract(DateTime.UtcNow).TotalMinutes > 120)
            {
                minutesUntilNextBump = 120;
            }
            else
            {
                minutesUntilNextBump = (int)Math.Round(lastBumpers[0].LastBump.AddHours(2f).Subtract(DateTime.UtcNow).TotalMinutes, 0);
            }

            if (minutesUntilNextBump == 0)
            {
                nextBumpString = "A new bump is available.";
            }
            else
            {
                nextBumpString = $"{minutesUntilNextBump} minutes left until next bump.";
            }

            foreach (BumpGameUser user in bumpGameUsers)
            {
                if (userPosition <= 5)
                {
                    userStatistics1 += $"{user.Name}:\n" +
                                       $"```" +
                                       $"      Player position: {userPosition}.\n" +
                                       $"      Points: {user.Points}.\n" +
                                       $"      First bump: {user.FirstBump}.\n" +
                                       $"      Last bump: {user.LastBump}." +
                                       $"```";
                }
                else if (userPosition > 5)
                {
                    userStatistics2 += $"{user.Name}:\n" +
                                       $"```" +
                                       $"      Player position: {userPosition}.\n" +
                                       $"      Points: {user.Points}.\n" +
                                       $"      First bump: {user.FirstBump}.\n" +
                                       $"      Last bump: {user.LastBump}." +
                                       $"```";
                }
                userPosition++;
            }


            EmbedFieldBuilder userStatisticsField1 = new EmbedFieldBuilder
            {
                IsInline = false,
                Name     = "Player Statistics:",
                Value    = userStatistics1
            };

            EmbedBuilder builder = new EmbedBuilder()
            {
                Color       = Color.Blue,
                Description = "These are the statistics for the bumping game,\n" +
                              "To play the game you simply run the `!d bump` command, every two hours a bump is available." +
                              "This command sets our server on the top of the disboard list, " +
                              "by playing this game you greatly help this server and it is appreciated by all staff.",
                Fields = new List <EmbedFieldBuilder>()
                {
                    new EmbedFieldBuilder()
                    {
                        IsInline = false,
                        Name     = "General Information:",
                        Value    = $"Current bot time: {DateTime.UtcNow.ToLongTimeString()}.\n" +
                                   $"Last bumped at: {lastBumpers[0].LastBump.TimeOfDay}.\n" +
                                   $"Next bump available at: {lastBumpers[0].LastBump.AddHours(2f).TimeOfDay}.\n" +
                                   $"Minutes until next bump: {nextBumpString} "
                    },
                    new EmbedFieldBuilder()
                    {
                        IsInline = false,
                        Name     = "Previous bumps:",
                        Value    = $"Last bump by: {lastBumpers[0].Name}.\n" +
                                   $"Second-last bump by: {lastBumpers[1].Name}."
                    },
                },
                Footer = new EmbedFooterBuilder()
                {
                    IconUrl = "https://cdn.discordapp.com/icons/509544906335715349/350ab64148a838ae9b116aa8b1948e0a.webp?size=1024",
                    Text    = "The Cyber Security Lounge."
                },
                Timestamp = DateTimeOffset.UtcNow,
                Title     = "Bump Game Statistics:",
                Url       = "https://disboard.org/server/509544906335715349"
            };

            builder.Fields.Add(userStatisticsField1);

            if (userPosition > 5)
            {
                EmbedFieldBuilder userStatisticsField2 = new EmbedFieldBuilder
                {
                    IsInline = false,
                    Name     = "Player Statistics:",
                    Value    = userStatistics2
                };
                builder.Fields.Add(userStatisticsField2);
            }

            await ReplyAsync("Here you go sweety these are the latest bump game statistics I could find :wink:.", false, builder.Build());
        }