Simp-O-Matic

Dumb Discord bot in TS.
git clone git://git.knutsen.co/Simp-O-Matic
Log | Files | Refs | README | LICENSE

commit e640beb9d5c8c868577e3c6ac9e12accc52c690c
parent f6e3f6c33a4a7d1e89207ba8501844d04feb0f2e
Author: Demonstrandum <moi@knutsen.co>
Date:   Mon, 23 Mar 2020 02:38:21 +0000

Fix weather.ts... maybe...

Diffstat:
Mlib/commands/weather.ts | 24++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/commands/weather.ts b/lib/commands/weather.ts @@ -30,19 +30,19 @@ export default (home_scope: HomeScope) => { const hour = (24 + date.getUTCHours() + tz) % 24; const country = !d.sys ? 'somewhere' : d.sys.country; - const embed = d.main?new Discord.MessageEmbed() - .setTitle(`${d.main.temp}°C (feels like ${d.main.feels_like}°C`) - .setAuthor(`${d.name}, ${country} ${hour}:${date.getMinutes()}`) - .setDescription(d.weather[0].description) - .setThumbnail(`https://openweathermap.org/img/wn/${d.weather[0].icon}@2x.png`) - .addFields( - {name: 'Day temp', value: d.main.temp_max + '°C', inline: true}, - {name: 'Night temp', value: d.main.temp_min + '°C', inline: true} - ) - :new Discord.MessageEmbed().setTitle(`Cannot get weather information from ${location}.`); + const embed = d.main + ? new MessageEmbed() + .setTitle(`${d.main.temp}°C (feels like ${d.main.feels_like}°C`) + .setAuthor(`${d.name}, ${country} ${hour}:${date.getMinutes()}`) + .setDescription(d.weather[0].description) + .setThumbnail(`https://openweathermap.org/img/wn/${d.weather[0].icon}@2x.png`) + .addFields( + { name: 'Day temp', value: d.main.temp_max + '°C', inline: true }, + { name: 'Night temp', value: d.main.temp_min + '°C', inline: true }) + : new MessageEmbed() + .setTitle(`Cannot get weather information from ${location}.`); message.channel.send(embed); - }) - .catch(error); + }).catch(error); } };