Exemplo n.º 1
0
        public Task <Result> Execute(CommandMetadata data, int amount)
        {
            var allKarma = ParentPlugin.GetKarmaDictionary();
            List <SocketGuildUser> inGuild = new List <SocketGuildUser> ();

            foreach (var entry in allKarma)   // Man I'm getting lazy with dictionary type naming. All those generic parameters yo.
            {
                SocketGuildUser user = data.Message.GetGuild()?.GetUser(entry.Key);
                if (user == null)
                {
                    continue;
                }
                inGuild.Add(user);
            }

            inGuild.OrderByDescending(x => ParentPlugin.GetKarma(x.Id).Total);
            inGuild = inGuild.GetRange(0, Math.Min(amount, inGuild.Count));

            string result = "```";

            foreach (SocketGuildUser user in inGuild)
            {
                result += StringExtensions.UniformStrings(user.GetShownName(), ParentPlugin.GetKarma(user.Id).ToString()) + "\n";
            }
            result += "```";

            return(TaskResult(inGuild, result));
        }