From ecc162549eb5966770922032796e55c1b88aaba3 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Mon, 4 Dec 2023 16:01:57 +0100 Subject: [PATCH] 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. --- commands/misc/weather.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/commands/misc/weather.js b/commands/misc/weather.js index 8f8bd76..4cf20eb 100644 --- a/commands/misc/weather.js +++ b/commands/misc/weather.js @@ -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); }