public async Task SearchRlPlayers([Remainder] string searchPlayer = null) { var embed = new EmbedBuilder(); embed.Title = "RL Stats Search"; if (searchPlayer != null) { StringBuilder sb = new StringBuilder(); var searchResults = await _rlsClient.SearchPlayerAsync(searchPlayer); if (searchResults != null) { if (searchResults.TotalResults > 1) { sb.AppendLine($"**Use the {_prefix}rlstats command with one of the following player names:**"); for (int i = 0; i <= searchResults.Data.Count() - 1; i++) { DateTime humanTime = searchResults.Data[i].UpdatedAt.UnixTimeStampToDateTimeSeconds(); embed.AddField(new EmbedFieldBuilder { Name = $":white_small_square: {searchResults.Data[i].DisplayName}", Value = $"Last Updated: [*{string.Format("{0:MM-dd-yy HH:mm}", humanTime)}*]", IsInline = true }); } } else if (searchResults.Data.Count() == 1) { DateTime humanTime = searchResults.Data[0].UpdatedAt.UnixTimeStampToDateTimeSeconds(); embed.AddField(new EmbedFieldBuilder { Name = $":white_small_square: {searchResults.Data[0].DisplayName}", Value = $"Last Updated: [*{string.Format("{0:MM-dd-yy HH:mm}", humanTime)}*]", IsInline = true }); } else { sb.AppendLine($"No players found with that name!"); } } embed.Description = sb.ToString(); } else { embed.Description = $"Please specify a user name to search for!"; } await _cc.Reply(Context, embed); }
private static async Task Run() { // Grabs RLS api key from environment variables. var apiKey = Environment.GetEnvironmentVariable("RLS_API_KEY"); // Initialize RLSClient. var client = new RLSClient(apiKey); // Retrieve a single player. var player = await client.GetPlayerAsync(RlsPlatform.Steam, "76561198033338223"); var playerSeasonSix = player.RankedSeasons.FirstOrDefault(x => x.Key == RlsSeason.Seven); if (playerSeasonSix.Value != null) { Console.WriteLine($"# Player: {player.DisplayName}"); foreach (var playerRank in playerSeasonSix.Value) { Console.WriteLine($"{playerRank.Key}: {playerRank.Value.RankPoints} rating"); } } // Retrieve multiple players. var players = await client.GetPlayersAsync(new[] { new PlayerBatchRequest(RlsPlatform.Steam, "76561198033338223"), new PlayerBatchRequest(RlsPlatform.Ps4, "Wizwonk"), new PlayerBatchRequest(RlsPlatform.Xbox, "Loubleezy") }); Console.WriteLine("Finished multiple players."); // Search for players. var players2 = await client.SearchPlayerAsync("AeonLucid"); Console.WriteLine("Finished search for players."); // Retrieve the top 100 players of a ranked playlist. var topPlayers = await client.GetLeaderboardRankedAsync(RlsPlaylistRanked.Standard); Console.WriteLine("Finished top 100 players of a ranked playlist."); // Retrieve the top 100 players of a stat type. var topPlayers2 = await client.GetLeaderboardStatAsync(RlsStatType.Wins); Console.WriteLine("Finished top 100 players of a stat type."); // Retrieve platform data. var platforms = await client.GetPlatformsAsync(); Console.WriteLine("Finished platform data."); // Retrieve seasons data. var seasons = await client.GetSeasonsAsync(); Console.WriteLine("Finished seasons data."); // Retrieve playlist (& population) data. var playlists = await client.GetPlaylistsAsync(); Console.WriteLine("Finished playlists data."); // Retrieve tiers data. var tiers = await client.GetTiersAsync(); Console.WriteLine("Finished tiers data."); // Retrieve tier data of a specific season. var tiers2 = await client.GetTiersAsync(RlsSeason.One); Console.WriteLine("Finished tier data of a specific season."); Console.WriteLine("Finished."); }