protected override async Task Execute(IDMCommandContext context) { EmbedBuilder inaraEmbed; if (!WebRequestService.CanMakeInaraRequests) { inaraEmbed = new EmbedBuilder() { Color = BotCore.ErrorColor, Title = INARAREQUESTFAILURE, Description = "Can not make inara requests, as appname and/or apikey config variables are not set!" }; } else { JSONContainer inaraRequestcontent = WebRequestService.Inara_CMDR_Profile(cmdrName); if (printJson) { await context.Channel.SendEmbedAsync(new EmbedBuilder() { Title = "Request JSON sending to Inara", Color = BotCore.EmbedColor, Description = $"```json\n{inaraRequestcontent.Build(true).MaxLength(EmbedHelper.EMBEDDESCRIPTION_MAX - 11)}```" }); } RequestJSONResult requestResultInara = await WebRequestService.GetWebJSONAsync("https://inara.cz/inapi/v1/", inaraRequestcontent); if (requestResultInara.IsSuccess && string.IsNullOrEmpty(requestResultInara.jsonParseError)) { inaraEmbed = GetInaraCMDREmbed(requestResultInara.JSON, cmdrName); if (printJson) { await context.Channel.SendEmbedAsync(new EmbedBuilder() { Title = "Result JSON from Inara", Color = BotCore.EmbedColor, Description = $"```json\n{requestResultInara.JSON.Build(true).MaxLength(EmbedHelper.EMBEDDESCRIPTION_MAX - 11)}```" }); } } else if (!string.IsNullOrEmpty(requestResultInara.jsonParseError)) { inaraEmbed = new EmbedBuilder() { Color = BotCore.ErrorColor, Title = INARAREQUESTFAILURE, Description = $"JSON parse error: `{requestResultInara.jsonParseError}`!" }; } else if (requestResultInara.IsException) { inaraEmbed = new EmbedBuilder() { Color = BotCore.ErrorColor, Title = INARAREQUESTFAILURE, Description = $"Could not connect to Inaras services. Exception Message: `{requestResultInara.ThrownException.Message}`" }; } else { inaraEmbed = new EmbedBuilder() { Color = BotCore.ErrorColor, Title = INARAREQUESTFAILURE, Description = $"Could not connect to Inaras services. HTTP Error Message: `{(int)requestResultInara.Status} {requestResultInara.Status}`" }; } } EmbedBuilder edsmEmbed; RequestJSONResult requestResultEDSM = await WebRequestService.GetWebJSONAsync(WebRequestService.EDSM_Commander_Location(cmdrName, true, false)); if (requestResultEDSM.IsSuccess && string.IsNullOrEmpty(requestResultEDSM.jsonParseError)) { edsmEmbed = GetEDSMCMDREmbed(requestResultEDSM.JSON, cmdrName); if (printJson) { await context.Channel.SendEmbedAsync(new EmbedBuilder() { Title = "Result JSON from EDSM", Color = BotCore.EmbedColor, Description = $"```json\n{requestResultEDSM.JSON.Build(true).MaxLength(EmbedHelper.EMBEDDESCRIPTION_MAX - 11)}```" }); } } else if (!string.IsNullOrEmpty(requestResultEDSM.jsonParseError)) { edsmEmbed = new EmbedBuilder() { Color = BotCore.ErrorColor, Title = EDSMREQUESTFAILURE, Description = $"JSON parse error: `{requestResultEDSM.jsonParseError}`!" }; } else if (requestResultEDSM.IsException) { edsmEmbed = new EmbedBuilder() { Color = BotCore.ErrorColor, Title = EDSMREQUESTFAILURE, Description = $"Could not connect to Inaras services. Exception Message: `{requestResultEDSM.ThrownException.Message}`" }; } else { edsmEmbed = new EmbedBuilder() { Color = BotCore.ErrorColor, Title = EDSMREQUESTFAILURE, Description = $"Could not connect to Inaras services. HTTP Error Message: `{(int)requestResultEDSM.Status} {requestResultEDSM.Status}`" }; } inaraEmbed.Footer = new EmbedFooterBuilder() { Text = "Inara" }; edsmEmbed.Footer = new EmbedFooterBuilder() { Text = "EDSM" }; await context.Channel.SendEmbedAsync(inaraEmbed); await context.Channel.SendEmbedAsync(edsmEmbed); }