if (msg.content.includes("?saa") && msg.author.bot === false){ let kaupunki = msg.content.split(" ")[1]; if (kaupunki === undefined ){ msg.reply("Ei löytynyt paikkakuntaa. Kutsu ?saa paikkakunta").catch(console.error) return; } else { fetch(`http://api.openweathermap.org/data/2.5/weather?q=${kaupunki}&lang=fi&APPID=e35aae3403c4248356a6a249c691860f`) .then(response => { return response.json() }).then(parsedWeather => { if (parsedWeather.cod === '404'){ msg.reply("Paikkakuntaa ei löydetty.") } else { msg.reply( ` Sää: Paikkakunta: ${parsedWeather.name}, :flag_${parsedWeather.sys.country.toLowerCase() }: Ennuste: ${parsedWeather.weather[0].description} :thermometer: atm: ${Math.round(((parsedWeather.main.temp - 273.15)))} °C :small_red_triangle: Ylin: ${Math.round(((parsedWeather.main.temp_max - 273.15)))} °C :small_red_triangle_down: Alin: ${Math.round(((parsedWeather.main.temp_min - 273.15)))} °C Päivä: ${new Date().toLocaleString() } ` ) } }) } }