public static EmbedBuilder CleanEmbed(EmbedBuilder embedToClean, bool isMinimal) { if (!isMinimal) { return(embedToClean); } var clone = embedToClean.DeepClone(); if (isMinimal) { clone.ImageUrl = null; clone.Fields.RemoveAll(field => field.Name == "Abilities" || field.Name == "Tags"); } return(clone); }
public async Task <EmbedBuilder> AddPriceAndImage(EmbedBuilder embed, bool isMinimal) { var clone = embed.DeepClone(); string realName = ""; if (clone.Description.Contains("Real Name")) { var description = clone.Description; var indexOne = description.IndexOf(':'); var indexTwo = description.IndexOf("**Format"); realName = description.Substring(indexOne, indexTwo).Trim(); } else { realName = clone.Title; } if (!isMinimal) { var result = await _yugiohService.GetPrices(clone.Title, realName); clone.ImageUrl = await _yugiohService.GetImageUrl(clone.Title, realName); if (result.data != null) { List <Datum> prices; if (result.data.Count >= 4) { clone.AddField(x => { x.Name = "Prices"; x.Value = "**Showing the first 3 prices due to too many to show**"; x.IsInline = false; }); prices = result.data.GetRange(0, 3); } else { prices = result.data; } foreach (Datum info in prices) { if (string.IsNullOrEmpty(info.price_data.message)) //check if there is an error message { var tempString = $"Rarity: {info.rarity}\n" + $"Average Price: ${info.price_data.data.prices.average.ToString("0.00")}"; clone.AddField(x => { x.Name = info.name; x.Value = tempString; x.IsInline = false; }); } else { clone.AddField(x => { x.Name = info.name; x.Value = info.price_data.message; x.IsInline = false; }); } } } else if (result.data == null) { clone.AddField(x => { x.Name = "Prices"; x.Value = "**No prices to show for this card!**"; x.IsInline = false; }); } return(clone); } else { clone.ThumbnailUrl = await _yugiohService.GetImageUrl(clone.Title, realName); return(clone); } }