Fix weather command properly.......

This commit is contained in:
SileNce5k 2023-12-06 17:49:34 +01:00
parent 3927b7905b
commit f5714cb90d
No known key found for this signature in database
GPG key ID: 961132EB78C8915F
2 changed files with 2 additions and 2 deletions

View file

@ -20,7 +20,7 @@ module.exports = {
// convert °C to °F and add it after C temperature in parentheses
let tempRegex = /(-?\d+)(?=°C)/g;
if(weather.success){
if(weather?.success){
let tempInCelsius = weather.weather.match(tempRegex)[0];
let tempInFahrenheit = Math.round(tempInCelsius * 1.8 + 32);
weather.weather = weather.weather.replace("°C", `°C (${tempInFahrenheit})°F`)

View file

@ -4,7 +4,7 @@ module.exports = async function (location) {
const options = {
hostname: "wttr.in",
port: 443,
path: `${location}?format=4&M`,
path: `/${location}?format=4&M`,
method: 'GET',
timeout: 5000
}