public async Task WeatherAsync([Remainder] string city) { var forecast = await _weather.GetForecastAsync(city, WeatherUnit.Imperial); if (forecast == null) { await ReplyAsync($"Could not find a city like `{city}`"); return; } var weather = forecast.Weather.First(); var embed = new EmbedBuilder() .WithColor(Color.Blue) .WithImageUrl(WeatherApiService.GetIconUrl(weather.IconId)) .WithTitle(forecast.Name + "'s Weather") .WithDescription(weather.Description) .WithCurrentTimestamp() .AddField("Pressure", forecast.Measurements.Pressure + " hPa", true) .AddField("Humidity", forecast.Measurements.Humidity + "%", true) .AddField("Temp", MathHelper.KelvinToFahrenheit(forecast.Measurements.Temperature) + "f", true) .AddField("Temp Range", MathHelper.KelvinToFahrenheit(forecast.Measurements.TemperatureMin) + "f -> " + MathHelper.KelvinToFahrenheit(forecast.Measurements.TemperatureMax) + 'f', true); await ReplyEmbedAsync(embed); }
public static async Task RunScheduledTask( [TimerTrigger("0 */1 * * * *")] TimerInfo timer, ILogger log) { foreach (var city in Cities) { JObject weather = await WeatherApiService.GetWeather(city); } }
public WeatherCommands(WeatherApiService weather) { weatherApi = weather; }
public WeatherModule(WeatherApiService weather, RootController root) : base(root) { _weather = weather; }