Exemple #1
0
        public static string GetUsernameIn(this ParsedRequest request, BotBitsClient client, int index)
        {
            var query = request.Args[index];
            PlayerSearchFilter filter;

            query = MatchHelper.TrimFilterPrefix(query, out filter);

            try
            {
                var list = request
                           .GetPlayersIn(client, index)
                           .Select(p => p.Username)
                           .Distinct()
                           .ToArray();

                if (!filter.HasFlag(PlayerSearchFilter.FirstResult) && list.Length >= 2)
                {
                    throw new CommandException("More than one username was found.");
                }

                return(list.First());
            }
            catch (UnknownPlayerCommandException)
            {
                return(query);
            }
        }
Exemple #2
0
        public static string[] GetUsernamesIn(this ParsedRequest request, BotBitsClient client, int index)
        {
            var query = request.Args[index];
            PlayerSearchFilter filter;

            query = MatchHelper.TrimFilterPrefix(query, out filter);

            try
            {
                return(request
                       .GetPlayersIn(client, index)
                       .Select(p => p.Username)
                       .Distinct()
                       .ToArray());
            }
            catch (UnknownPlayerCommandException)
            {
                return(new [] { query });
            }
        }