public async Task OverwatchStatsCommand(string platform, string region, [Remainder] string battletag) { platform = platform.ToLower(); region = region.ToLower(); var fixedBattletag = battletag.Replace('#', '-'); if (!ValidPlatforms.Any(x => x == platform)) { await ReplyAsync($"The platform '{platform}' is invalid. Valid platforms: {string.Join(", ", ValidPlatforms)}"); return; } if (!ValidRegions.Any(x => x == region)) { await ReplyAsync($"The region '{region}' is invalid. Valid regions: {string.Join(", ", ValidRegions)}"); return; } var responseString = await TryGetApiData(platform, region, fixedBattletag); var overwatchData = OverwatchStats.FromJson(responseString); if (string.IsNullOrEmpty(overwatchData?.Name)) { await ReplyAsync($"Could not get any profile stats on platform '{platform}' in region '{region}' with the battletag '{battletag}'"); return; } var builder = GetMessage(overwatchData); await ReplyAsync(embed : builder.Build()); }
private static EmbedBuilder GetMessage(OverwatchStats overwatchStats) { var raiting = overwatchStats.Rating != 0 ? $"<:{overwatchStats.RatingName}:{GetEmojiCode(overwatchStats.RatingName)}> {overwatchStats.RatingName} - {overwatchStats.Rating}" : "Unranked"; EmbedBuilder builder = new EmbedBuilder() .WithTitle($"Overwatch Stats - {overwatchStats.Name} ") .WithDescription($"Raiting: {raiting}\n" + $"Total Level: {overwatchStats.Prestige * 100 + overwatchStats.Level}\n" + $"Games Won: {overwatchStats.GamesWon}") .WithFooter($"Data from https://ow-api.com/") .WithCurrentTimestamp() .WithColor(Color.LightOrange) .WithImageUrl(overwatchStats.RatingIcon); return(builder); }