public WeatherApi Weather() { using (WebClient webclient = new WebClient()) { string json = webclient.DownloadString("http://api.openweathermap.org/data/2.5/weather?q=vejle&mode=json&units=metric&appid=e9b3b99c257810d4beaf8dc7be2a0c44"); return(WeatherApi.FromJson(json)); } }
public async Task Weather(CommandContext c, string Location) { var Results = await $"http://api.openweathermap.org/data/2.5/weather?q={Location}&APPID=471d2fb334519d7ddfbb8ceec590a3e2" .GetStringAsync(); var Data = WeatherApi.FromJson(Results); var Main = Data.Main; var Weather = new DiscordEmbedBuilder() .WithColor(new DiscordColor(0x1DE9B6)) .WithAuthor($"{c.Client.CurrentApplication.Name}'s weather report for: {Data.Name} {Data.Sys.Country}") .AddField("Base", $"{Data.Base}") .AddField("Wind", $"Wind Speed: {Data.Wind.Speed}\n" + $"Wind Direction: {Data.Wind.Deg}") .AddField("Clouds", $"{Data.Clouds.All}") .AddField("Main", $"Temperature: {Main.Temp} Min: {Main.TempMin} Max: {Main.TempMax}\n" + $"Humidity: {Main.Humidity}\n" + $"Atmospheric Pressure: {Main.Pressure}") .AddField("Coordinates", $"{Data.Coord.Lat} {Data.Coord.Lon}"); await c.RespondAsync(embed : Weather); }