Simp-O-Matic

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

commit f6e3f6c33a4a7d1e89207ba8501844d04feb0f2e
parent 15b05d4d9777069e1d1e466efa70fb6d740ebbd2
Author: danyisill <danyisill@users.noreply.github.com>
Date:   Mon, 23 Mar 2020 05:33:13 +0300

Merge branch 'master' of https://github.com/Demonstrandum/Simp-O-Matic

Ass

Diffstat:
Mlib/commands/system.ts | 10+++++-----
Mlib/main.ts | 17+++++++++++------
2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/lib/commands/system.ts b/lib/commands/system.ts @@ -1,7 +1,7 @@ import { help_info } from '../utils'; -const sys_channel = (channel: string) => - (channel) - ? `is set to ${channel}.` +const sys_channel = (channel_id: string) => + (channel_id) + ? `is set to <#${channel_id}>.` : `has not been set.`; export default (home_scope: HomeScope) => { @@ -23,9 +23,9 @@ export default (home_scope: HomeScope) => { if (channels.size === 0) return message.reply('System-information channel ' + sys_channel(CONFIG.system_channel)); - CONFIG.system_channel = channels.first().toString(); + CONFIG.system_channel = channels.first().id; return message.reply( - `System-information channel set to ${CONFIG.system_channel}.`); + `System-information channel set to <#${CONFIG.system_channel}>.`); } message.reply(help_info('system', CONFIG.commands.prefix)); diff --git a/lib/main.ts b/lib/main.ts @@ -97,10 +97,12 @@ export class SimpOMatic { this._CLIENT.login( SECRETS.api.token, `${__dirname}/*Discord.ts` - ); - console.log('Secrets:', pp(SECRETS)); - console.log('Known commands:', pp(KNOWN_COMMANDS)); - system_message(this._CLIENT, 'We\'re back online baby!'); + ).then(() => { + console.log('Bot logged in.') + setTimeout(() => + system_message(this._CLIENT, "**We're back online baby!**"), + 2000); + }); return this._CLIENT; } @@ -414,8 +416,11 @@ function on_termination(error_type) { console.warn(`Received ${error_type}, shutting down.`); console.log('Cleaning up...'); write_file(`${process.cwd()}/export-exit.json`, export_config(GLOBAL_CONFIG, {})); - pastebin_update(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...**`); @@ -423,7 +428,7 @@ function on_termination(error_type) { setTimeout(() => { console.log('Clean finished.'); process.exit(0); - }, 6000).unref(); + }, 3000).unref(); } // Handle exits.