public async Task GetUserSeason(EventContext e) { int platform = 1; string[] arg = e.arguments.Split(' '); int seasonId = int.Parse(arg[1]); if (arg.Length > 2) { platform = GetPlatform(arg[2]); } IDiscordEmbed embed = Utils.Embed; RocketLeagueUser user = await TryGetUser(arg[0], platform); if (user == null) { embed.Title = "Uh oh!"; embed.Description = $"We couldn't find a user with the name `{arg[0]}`. Please look up yourself on https://rlstats.com/ to create your profile!"; embed.ThumbnailUrl = "http://miki.veld.one/assets/img/rlstats-logo.png"; await e.Channel.SendMessage(embed); return; } embed.Title = $"{user.DisplayName}'s Season {arg[1]}"; if (user.RankedSeasons.ContainsKey(seasonId)) { Dictionary <int, RocketLeagueRankedStats> rankedseason = user.RankedSeasons[seasonId]; foreach (RocketLeaguePlaylist playlist in api.playlists.Data) { if (rankedseason.ContainsKey(playlist.Id)) { if (playlist.PlatformId == platform) { RocketLeagueRankedStats stats = rankedseason[playlist.Id]; string rank = ""; RocketLeagueTier t = api.tiers.Data.Find(z => { return(z.Id == stats.Tier); }); if (t != null) { rank = t.Name + " " + stats.Division; embed.AddField(f => { f.Name = playlist.Name.Substring(7); f.Value = $"Rank: {rank}\n\nMMR: {stats.RankPoints}\nMatches Played: {stats.MatchesPlayed}"; f.IsInline = true; }); } } } } } await e.Channel.SendMessage(embed); }
public async Task GetUser(EventContext e) { string[] arg = e.arguments.Split(' '); int platform = 1; if (arg.Length > 1) { platform = GetPlatform(arg[1]); } IDiscordEmbed embed = Utils.Embed; RocketLeagueUser user = await TryGetUser(arg[0], platform); if (user == null) { embed.Title = "Uh oh!"; embed.Description = $"We couldn't find a user with the name `{arg[0]}`. Please look up yourself on https://rlstats.com/ to create your profile!"; embed.ThumbnailUrl = "http://miki.veld.one/assets/img/rlstats-logo.png"; await e.Channel.SendMessage(embed); return; } embed.Title = user.DisplayName; foreach (RocketLeagueSeason season in api.seasons.Data) { if (user.RankedSeasons.ContainsKey(season.Id)) { Dictionary <int, RocketLeagueRankedStats> rankedseason = user.RankedSeasons[season.Id]; string s = ""; foreach (RocketLeaguePlaylist playlist in api.playlists.Data) { if (rankedseason.ContainsKey(playlist.Id)) { if (playlist.PlatformId == platform) { RocketLeagueRankedStats stats = rankedseason[playlist.Id]; s += "`" + playlist.Name.Substring(7).PadRight(13) + ":` " + stats.RankPoints.ToString() + " MMR\n"; } } } embed.AddField(f => { f.Name = "Season" + season.Id; f.Value = s; f.IsInline = true; }); } } embed.ThumbnailUrl = user.AvatarUrl; embed.ImageUrl = user.SignatureUrl; await e.Channel.SendMessage(embed); }