public EmbedBuilder CreateScorersEmbed(IList <Scorer> scorers) { var builder = new EmbedBuilder() .WithTitle("LaLiga Current Top Scorers") .WithColor(Color.Orange) .WithThumbnailUrl( "https://assets.laliga.com/assets/logos/laliga-v-negativo/laliga-v-negativo-1200x1200.jpg") .WithFooter($"Stats updated at {scorers.First().UpdatedAt:dd/MM/yyyy HH:mm} UTC"); foreach (var scorer in scorers) { builder.AddField($"{scorer.Id + 1}. {scorer.Name}, {scorer.Goals} goals", $"{_emojiService.GetEmojiString(scorer.Nationality)}, {scorer.Team.Name}"); } return(builder); }
public EmbedBuilder CreatePlayerEmbed(Player player) { var stats = player.Statistics; var flag = _emojiService.GetEmojiString(player.Nationality); var builder = new EmbedBuilder() .WithTitle($"{player.Name} {flag}") .WithColor(Color.Purple) .WithDescription( $"Position: {player.Position.ToString()}, Age: {player.Age}, Height: {player.Height}, Weight: {player.Weight}" ) .WithFooter($"Stats last updated at {player.UpdatedAt:dd/MM/yyyy HH:mm} UTC") .AddField("Games played", stats.Games.Appearances) .AddField("Goals", stats.Goals.Total) .AddField("Assists", stats.Goals.Assists) .AddField("Rating", stats.Rating is null ? "0" : $"{stats.Rating:0.##}"); var converter = new ToPer90Converter(stats.Games.MinutesPlayed); switch (player.Position) { case Position.Attacker: AddShots(); AddPasses(); AddDribbles(); break; case Position.Midfielder: AddPasses(); AddDribbles(); AddTackles(); break; case Position.Defender: AddGoalsConceded(); AddTackles(); AddPasses(); break; case Position.Goalkeeper: AddGoalsConceded(); AddPasses(); break; case Position.None: break; default: throw new ArgumentOutOfRangeException(); } return(builder); void AddShots() { var shotsTotal = converter.ToPer90(stats.Shots.Total); var shotsOnTarget = converter.ToPer90(stats.Shots.OnTarget); var percentageShotsOnTarget = shotsOnTarget / shotsTotal; builder.AddField("Shots per 90 minutes", $"Total: {shotsTotal:0.##}, On Target: {shotsOnTarget:0.##} ({percentageShotsOnTarget:0.##%})"); } void AddPasses() { builder.AddField("Passes per 90 minutes", $"Total: {converter.ToPer90(stats.Passes.Total):0.##}, Key passes: {converter.ToPer90(stats.Passes.Key):0.##}, Accuracy: {stats.Passes.Accuracy:0.##}%" ); } void AddDribbles() { var dribblesAttempted = converter.ToPer90(stats.Dribbles.Attempts); var dribblesSuccessful = converter.ToPer90(stats.Dribbles.Success); var percentageDribblesSuccessful = dribblesSuccessful / dribblesAttempted; builder.AddField("Dribbles per 90 minutes", $"Attempted: {dribblesAttempted:0.##}, Successful: {converter.ToPer90(stats.Dribbles.Success):0.##} ({percentageDribblesSuccessful:0.##%})" ); } void AddTackles() { builder.AddField("Tackles per 90 minutes", $"Tackles: {converter.ToPer90(stats.Tackles.Total):0.##}, Interceptions: {converter.ToPer90(stats.Tackles.Interceptions):0.##}, Blocks: {converter.ToPer90(stats.Tackles.Blocks):0.##}" ); } void AddGoalsConceded() { builder.AddField("Goals conceded:", stats.Goals.Conceded); } }