Esempio n. 1
0
        public async Task IPLocation(CommandContext ctx,
                                     [Description("IP Address")] string address)
        {
            if (string.IsNullOrWhiteSpace(address) || !IPAddress.TryParse(address, out IPAddress ip))
            {
                return;
            }
            var results = GoogleService.GetIPLocationAsync(ip).Result;

            if (results.Status != "success")
            {
                await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_LOCATION, EmbedType.Warning).ConfigureAwait(false);
            }
            else
            {
                var output = new DiscordEmbedBuilder()
                             .WithDescription($"Location: { results.City}, { results.Region}, { results.Country}")
                             .AddField("Longitude", results.Longitude.ToString(), true)
                             .AddField("Latitude", results.Latitude.ToString(), true)
                             .AddField("ISP", results.ISP)
                             .WithFooter($"IP: {results.Query}")
                             .WithColor(new DiscordColor("#4d2f63"));
                await ctx.RespondAsync(embed : output.Build()).ConfigureAwait(false);
            }
        }
Esempio n. 2
0
 public void GetIPLocation()
 {
     Assert.IsTrue(GoogleService.GetIPLocationAsync(IPAddress.Parse("123.123.123.123")).Result.Status == "success");
 }