public async Task SearchUser(EventContext e) { string[] arg = e.arguments.Split(' '); IDiscordEmbed embed = Utils.Embed; RocketLeagueSearchResult user = await api.SearchUsersAsync(arg[0], (arg.Length >= 2)?int.Parse(arg[1]) : 0); embed.Title = $"Found {user.TotalResults} users with the name `{arg[0]}`"; embed.CreateFooter(); embed.Footer.Text = $"Page {user.Page} of ${(int)Math.Ceiling((double)user.TotalResults / user.MaxResultsPerPage)}"; List <string> names = new List <string>(); user.Data.ForEach(z => { names.Add(z.DisplayName); }); embed.Description = string.Join(", ", names); embed.QueueToChannel(e.Channel); }
public async Task <RocketLeagueUser> TryGetUser(string name, int platform) { RocketLeagueUser user = await api.GetUserAsync(name, platform); if (user.DisplayName == null || user.DisplayName == "") { RocketLeagueSearchResult result = await api.SearchUsersAsync(name, 0, true); if (result.Data.Count > 0) { user = result.Data[0]; } else { return(null); } } return(user); }