Use replace instead of splitting for fahrenheit

Didn't know replace was a thing, so I did it in a kinda of shitty way
before. Shouldn't be much difference except for the code being more
understandable.
This commit is contained in:
SileNce5k 2023-12-04 16:01:57 +01:00
parent d8649ff943
commit ecc162549e
No known key found for this signature in database
GPG key ID: 961132EB78C8915F

View file

@ -20,9 +20,8 @@ module.exports = {
let tempRegex = /(-?\d+)(?=°C)/g;
if(weather.success){
let tempInCelsius = weather.weather.match(tempRegex)[0];
let tempInFahrenheit = `(${Math.round(tempInCelsius * 1.8 + 32)}°F)`;
let splitWeather = weather.weather.split("°C");
weather.weather = `${splitWeather[0]}°C ${tempInFahrenheit} ${splitWeather[1]}`
let tempInFahrenheit = Math.round(tempInCelsius * 1.8 + 32);
weather.weather = weather.weather.replace("°C", `°C ${tempInFahrenheit}°F`)
}
message.channel.send(weather.weather);
}