Simp-O-Matic

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

commit d543175036be39f86529e24d32780088b44ada83
parent b53f9450f155177efa4ff17d7d9217686fff3ad4
Author: Demonstrandum <moi@knutsen.co>
Date:   Mon, 23 Mar 2020 14:20:39 +0000

Remove shameful if-statement.

Diffstat:
Mlib/commands/weather.ts | 5++---
Mlib/main.ts | 28+++++++++++++---------------
2 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/lib/commands/weather.ts b/lib/commands/weather.ts @@ -33,8 +33,7 @@ export default (home_scope: HomeScope) => { const tz = d.timezone / 3600; // Now in hours. const tz_frac = tz % 1; // Fractional part in hours. - if (tz_frac === 0) - date.setMinutes(date.getMinutes() + tz_frac * 60); + date.setMinutes(date.getMinutes() + tz_frac * 60); const hour = ((24 + date.getUTCHours() + tz - tz_frac) % 24) .toFixed().padStart(2, '0'); @@ -51,7 +50,7 @@ export default (home_scope: HomeScope) => { { name: 'daytime', value: d.main.temp_max + '°C', inline: true }, { name: 'nighttime', value: d.main.temp_min + '°C', inline: true }, { name: 'humidity', value: d.main.humidity + '%', inline: true }, - { name: 'wind', value: `${directions[Math.round(d.wind.deg / 45)]} ${d.wind.speed} m/s`, inline: true }) + { name: 'wind', value: `${directions[Math.round(d.wind.deg / 45)]} ${d.wind.speed} ㎧`, inline: true }) : new MessageEmbed() .setTitle(`Cannot get weather information from ${location}.`); diff --git a/lib/main.ts b/lib/main.ts @@ -440,21 +440,19 @@ function on_termination(error_type) { // Back-up the resultant CONFIG to an external file. console.warn(`Received ${error_type}, shutting down.`); - if (error_type === 'exit') - write_file( - `${process.cwd()}/export-exit.json`, - export_config(GLOBAL_CONFIG, {})); - - if (error_type === 'beforeExit') { - pastebin_update(export_config(GLOBAL_CONFIG, {})) - .then(_ => console.log('Finished pastebin update.')) - .catch(e => console.warn('Pastebin not saved!', e)); - // Message all system channels. - console.log('Sending system messages.'); - system_message(CLIENT, - `Bot got \`${error_type}\` signal.\n` - + `**Shutting down...**`); - } + write_file( + `${process.cwd()}/export-exit.json`, + export_config(GLOBAL_CONFIG, {})); + + pastebin_update(export_config(GLOBAL_CONFIG, {})) + .then(_ => console.log('Finished pastebin update.')) + .catch(e => console.warn('Pastebin not saved!', e)); + // Message all system channels. + console.log('Sending system messages.'); + system_message(CLIENT, + `Bot got \`${error_type}\` signal.\n` + + `**Shutting down...**`); + // Make sure we saved ok. setTimeout(() => { console.log('Clean finished.');