From 05fb19d528b471e00ed723a8700a086fcd23d2f5 Mon Sep 17 00:00:00 2001 From: blakewenloe Date: Thu, 4 Jul 2019 17:20:22 -0400 Subject: [PATCH] fixed empty fields containing units --- modules/getWeather.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/modules/getWeather.js b/modules/getWeather.js index a282d43..86a90ee 100644 --- a/modules/getWeather.js +++ b/modules/getWeather.js @@ -36,30 +36,38 @@ function getWeather(callsign, message) { ); return; } else { - let temp = data.entries[0].temp || "Not available"; + let temp = data.entries[0].temp + ? `${data.entries[0].temp}C` + : "Not available"; let pressure = data.entries[0].pressure || "Not available"; let humidity = data.entries[0].humidity || "Not available"; let wind_direction = data.entries[0].wind_direction || "Not available"; let wind_speed = data.entries[0].wind_speed || "Not available"; let wind_gust = data.entries[0].wind_gust || "Not available"; - let rain_1h = data.entries[0].rain_1h || "Not available"; - let rain_24h = data.entries[0].rain_24h || "Not available"; - let rain_mn = data.entries[0].rain_mn || "Not available"; + let rain_1h = data.entries[0].rain_1h + ? `${data.entries[0].rain_1h}mm` + : "Not available"; + let rain_24h = data.entries[0].rain_24h + ? `${data.entries[0].rain_24h}mm` + : "Not available"; + let rain_mn = data.entries[0].rain_mn + ? `${data.entries[0].rain_mn}mm` + : "Not available"; let luminosity = data.entries[0].luminosity || "Not available"; timeUpdated = new Date(data.entries[0].time * 1000); - let miniMapUrl = `http://www2.findu.com/cgi-bin/radar-find.cgi?call=${callsign}`; + let miniMapUrl = `http://www.findu.com/cgi-bin/radar-find.cgi?call=${callsign}`; let locationEmbed = new Discord.RichEmbed() .setColor(config.embed_color) .setAuthor("APRS Bot") - .addField("Temp", `${temp}C`) + .addField("Temp", temp) .addField("Pressure", pressure) .addField("Humidity", humidity) .addField("Wind direction", wind_direction) .addField("Wind speed", wind_speed) .addField("Wind gust", wind_gust) - .addField("Rainfall past 1hr", `${rain_1h}mm`) - .addField("Rainfall past 24hrs", `${rain_1h}mm`) - .addField("Rainfall since midnight", `${rain_mn}mm`) + .addField("Rainfall past 1hr", rain_1h) + .addField("Rainfall past 24hrs", rain_1h) + .addField("Rainfall since midnight", rain_mn) .addField("Luminosity", luminosity) .addField("Time", timeUpdated.toLocaleString("en-US", dateOptions)) .setImage(miniMapUrl)