Exemple #1
0
            public Task <Result> Execute(SocketUserMessage e, string gamename)
            {
                UserGameMonitor.PurgeData();
                string foundGame = gamename;
                List <SocketGuildUser> foundUsers = UserGameMonitor.FindUsersWithGame(ref foundGame);

                if (foundUsers.Count == 0)
                {
                    return(TaskResult("", "Sorry, no records of **" + foundGame + "** being played were found."));
                }
                else
                {
                    string total = "Here is the list of everyone who've been seen playing **" + foundGame + "**:```\n";
                    foreach (SocketGuildUser user in foundUsers)
                    {
                        total += Utility.GetUserName(user) + "\n";
                    }
                    total += "```";
                    return(TaskResult(total, total));
                }
            }
Exemple #2
0
        public async Task <Result> Execute(SocketUserMessage message)
        {
            UserGameMonitor.PurgeData();
            Dictionary <string, int> passedGames = new Dictionary <string, int> ();
            int count = UserGameMonitor.userGames.Count();

            string all = "";

            for (int i = 0; i < count; i++)
            {
                List <string> within = UserGameMonitor.userGames.ElementAt(i).Value;
                foreach (string game in within)
                {
                    if (!passedGames.ContainsKey(game))
                    {
                        passedGames.Add(game, 1);
                    }
                    else
                    {
                        passedGames [game]++;
                    }
                }
            }

            // Linq is wierd shit yo. Also use var just because otherwise it's a really long type.
            var items = from pair in passedGames
                        orderby pair.Value descending
                        select pair;

            count = items.Count();
            for (int i = 0; i < count; i++)
            {
                all += Utility.UniformStrings(items.ElementAt(i).Key, "Players: " + items.ElementAt(i).Value + "\n", " - ");
            }
            RestUserMessage userMessage = await Program.messageControl.SendBookMessage(message.Channel, "All games seen played on this server:", all, allowInMain, "```");

            return(new Result(userMessage, "All games played on this server:"));
        }