public async Task <Embed> GetItem(ulong itemId) { Item item = await ItemAPI.Get(itemId); EmbedBuilder embed = item.ToEmbed(); if (item.IsUntradable != 1) { (MarketAPI.History? hq, MarketAPI.History? nm) = await MarketAPI.GetBestPriceHistory("Elemental", itemId); if (hq != null | nm != null) { StringBuilder builder = new StringBuilder(); if (hq != null) { builder.Append(hq.ToStringEx()); } if (nm != null) { builder.Append(nm.ToStringEx()); } embed.AddField("Best Market Board Prices", builder.ToString()); } } return(embed.Build()); }
public async Task <Embed> GetMarketBoardItem(ulong itemId) { Item item = await ItemAPI.Get(itemId); EmbedBuilder embed = item.ToMbEmbed(); if (item.IsUntradable != 1) { IOrderedEnumerable <MarketAPI.History> prices = await MarketAPI.GetBestPriceFromAllWorlds("Elemental", itemId); if (prices.Any()) { StringBuilder hqBuilder = new StringBuilder(); StringBuilder nqBuilder = new StringBuilder(); if (prices.Any(x => x.Hq == true)) { hqBuilder.AppendLine("High Quality"); } if (prices.Any(x => x.Hq == false)) { nqBuilder.AppendLine("Normal Quality"); } foreach (MarketAPI.History price in prices) { if (price.Hq == true) { hqBuilder.AppendLine(Utils.Characters.Tab + price.ToStringEx()); } if (price.Hq == false) { nqBuilder.AppendLine(Utils.Characters.Tab + price.ToStringEx()); } } if (hqBuilder.Length > 0 && nqBuilder.Length > 0) { hqBuilder.AppendLine(); } embed.AddField("Best Market Board Prices", hqBuilder.ToString() + nqBuilder.ToString()); } } return(embed.Build()); }
private async Task <Embed> GetMarketBoardEmbed(ulong itemId, bool?hqOnly = null, bool lowestByUnitPrice = false) { Item item = await ItemAPI.Get(itemId); // If item cannot be hq, ensure filter isn't hq only if (hqOnly == true && item.CanBeHq != 1) { hqOnly = null; } string tab = Utils.Characters.Space; EmbedBuilder embed = item.ToMbEmbed(); embed.Description += "\n"; if (item.IsUntradable != 1) { IOrderedEnumerable <MarketAPI.ListingDisplay> listings = await MarketAPI.GetBestPriceListing("Elemental", itemId, hqOnly, lowestByUnitPrice); if (listings.Any()) { // Variables for world name spacing int longestWorldNameLength = listings.Max(x => x.WorldName?.Length ?? 0); int worldGap; string worldGapString; // Do thing StringBuilder builder = new StringBuilder(); builder.AppendLine(Utils.Characters.Space); foreach (MarketAPI.ListingDisplay listing in listings) { worldGap = longestWorldNameLength - (listing.WorldName?.Length ?? 0); worldGapString = "{0}"; for (int i = 0; i < worldGap; i++) { worldGapString += "{0}"; } string line = string.Format( "{5} `{1} " + worldGapString + " {2} x {3}{4}`", tab, listing.WorldName, listing.Quantity, listing.MaxPricePerUnit, listing.Quantity == 1 ? string.Empty : " (" + listing.MaxTotal + ")", listing.Hq == true ? ItemService.HighQualityEmote : ItemService.NormalQualityEmote); builder.AppendLine(line); } builder.AppendLine(); builder.AppendLine($"Use {ItemService.HQEmote} to toggle HQ Only."); builder.AppendLine($"Use {ItemService.GilIEmote} to toggle sorting by Unit Price/Total Price."); embed.AddField("Best Market Board Prices", builder.ToString()); } } return(embed.Build()); }