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); } }
public static Player[] GetPlayersIn(this ParsedRequest request, BotBitsClient client, int index) { var query = request.Args[index]; PlayerSearchFilter filter; query = MatchHelper.TrimFilterPrefix(query, out filter); return(MatchPlayers(client, query, filter)); }
public static Player GetPlayerIn(this ParsedRequest request, BotBitsClient client, int index) { var query = request.Args[index]; PlayerSearchFilter filter; query = MatchHelper.TrimFilterPrefix(query, out filter); var list = MatchPlayers(client, query, filter); if (!filter.HasFlag(PlayerSearchFilter.FirstResult) && list.Length >= 2) { throw new CommandException("More than one player was found."); } return(list.First()); }
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 }); } }