public virtual async Task TM_JumpRange(string sector = null, string hex = null, string jump = null, bool verbose = false) { if (string.IsNullOrEmpty(sector) || sector == "?") { await SendHelpMessage($"Usage: {BotConfiguration.thisBotConfig.CommandIndicator}world-jump spin 1910 4", "Get worlds in a given jump range of a sector hex\nThis can me made verbose if you put true on the end, e.g. [~]world-jump spin 1910 4 true", $"{BotConfiguration.thisBotConfig.CommandIndicator}world-jump <sector> <hex> <range> <verbose>"); return; } EmbedBuilder msg = null; if (mapService != null) { try { string json = GetResponse(mapService.TravellerMapAPI[Enums.TravellerAPIMapEnums.Jump_Range].Replace("/sector", $"/{sector}").Replace("/hex", $"/{hex}").Replace("/range", $"/{jump}")); WorldsHex worlds = DeserializeJSON <WorldsHex>(json); if (worlds.Worlds != null && worlds.Worlds.Count > 0) { if (!verbose) { msg = GetMsg(defaultColor, $"Jump Range of {jump}", $"{worlds.Worlds.Count} Worlds Found"); } int cnt = 0; int tcnt = 0; foreach (World world in worlds.Worlds) { if (verbose) { msg = GetWorldMessage(world); await SendMessageAsync(msg); } else { GetWorldMessage(world, msg); cnt++; tcnt++; if (cnt == 5) { cnt = 0; await SendMessageAsync(msg, null, $"{tcnt}/{worlds.Worlds.Count} continued..."); msg = GetMsg(defaultColor, $"...", null, null, "...continued"); } } } if (!verbose) { await SendMessageAsync(msg); } } else { msg = GetMsg(defaultColor, $"{sector} {hex}", "No wrolds found in range.."); await SendMessageAsync(msg); } } catch (Exception ex) { msg = GetErrorMsg($"Error:\n{ex.Message}", Context.User); await SendMessageAsync(msg); } } else { msg = GetErrorMsg("Service does not use Traveller API", Context.User); await SendMessageAsync(msg); } }
public virtual async Task TM_WorldHex(string sector = null, string hex = null, bool verbose = true) { if (string.IsNullOrEmpty(sector) || sector == "?") { await SendHelpMessage($"Usage: {BotConfiguration.thisBotConfig.CommandIndicator}world-hex 1910", "Get world data from a given hex in a sector", $"{BotConfiguration.thisBotConfig.CommandIndicator}world-hex <sector> <hex>"); return; } EmbedBuilder msg = null; if (mapService != null) { try { string json = GetResponse(mapService.TravellerMapAPI[Enums.TravellerAPIMapEnums.World_Data].Replace("/sector", $"/{sector}").Replace("/hex", $"/{hex}")); WorldsHex worlds = DeserializeJSON <WorldsHex>(json); if (worlds.Worlds != null && worlds.Worlds.Count > 0) { if (!verbose) { msg = GetMsg(defaultColor, $"World Found", $"{hex}"); } foreach (World world in worlds.Worlds) { if (verbose) { msg = GetWorldMessage(world); await SendMessageAsync(msg); } else { GetWorldMessage(world, msg); } } if (!verbose) { await SendMessageAsync(msg); } } else { msg = GetMsg(defaultColor, $"{sector} {hex}", "No wrolds found here.."); await SendMessageAsync(msg); } } catch (Exception ex) { msg = GetErrorMsg($"Error:\n{ex.Message}", Context.User); await SendMessageAsync(msg); } } else { msg = GetErrorMsg("Service does not use Traveller API", Context.User); await SendMessageAsync(msg); } }