public async Task Wolfram([Remainder] string text) { string wolframToken = _config["tokens:wolframalpha"]; WolframAlphaClient client = new WolframAlphaClient(wolframToken); FullResultRequest request = new FullResultRequest(text); request.ScanTimeout = 8; FullResultResponse results = await client.FullResultAsync(request).ConfigureAwait(false); if (results.IsError) { await ReplyAsync($"Error: {results.ErrorDetails.Message}"); } //Results are split into "pods" that contain information. Those pods can have SubPods. foreach (Pod pod in results.Pods) { foreach (SubPod subPod in pod.SubPods) { var builder = new EmbedBuilder() { Color = new Color(114, 137, 218), }; string value = (subPod.Image.Height <= 21) ? subPod.Image.Alt : "Shown below"; string name = string.IsNullOrEmpty(subPod.Title) ? pod.Title : subPod.Title; if (!string.IsNullOrEmpty(subPod.Image.Src.ToString()) && subPod.Image.Height > 21) { builder.ImageUrl = subPod.Image.Src.ToString(); } builder.AddField(x => { x.Name = name; x.IsInline = false; x.Value = value; }); await ReplyAsync("", false, builder.Build()); } } }
private static async Task Main(string[] args) { //Create the client. WolframAlphaClient client = new WolframAlphaClient(_appId); FullResultRequest request = new FullResultRequest("100 digits of pi"); request.Formats = Format.Plaintext; //We start a new query. FullResultResponse results = await client.FullResultAsync(request).ConfigureAwait(false); //Here we output the Wolfram|Alpha results. if (results.IsError) { Console.WriteLine("Woops, where was an error: " + results.ErrorDetails.Message); } Console.WriteLine(); //Results are split into "pods" that contain information. Those pods can have SubPods. foreach (Pod pod in results.Pods) { Console.WriteLine(pod.Title + ":"); foreach (SubPod subPod in pod.SubPods) { if (string.IsNullOrEmpty(subPod.Plaintext)) { Console.WriteLine("<Cannot output in console>"); } else { Console.WriteLine(subPod.Plaintext); } } Console.WriteLine(); } }