From 15d4e251f2af47288b4d5720b8a7b763e72731c0 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Tue, 17 Mar 2020 17:59:26 -0500 Subject: Add better responses --- src/utils/debug.ts | 3 +++ src/utils/error-msg.ts | 13 +++++++++++++ src/utils/loading-message.ts | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/utils/debug.ts create mode 100644 src/utils/error-msg.ts (limited to 'src/utils') diff --git a/src/utils/debug.ts b/src/utils/debug.ts new file mode 100644 index 0000000..ee33384 --- /dev/null +++ b/src/utils/debug.ts @@ -0,0 +1,3 @@ +import debug from 'debug'; + +export default debug('muse'); diff --git a/src/utils/error-msg.ts b/src/utils/error-msg.ts new file mode 100644 index 0000000..7325776 --- /dev/null +++ b/src/utils/error-msg.ts @@ -0,0 +1,13 @@ +export default (error?: string | Error): string => { + let str = '🚫 unknown error'; + + if (error) { + if (typeof error === 'string') { + str = `🚫 ${error}`; + } else if (error instanceof Error) { + str = `🚫 error: ${error.name}`; + } + } + + return str; +}; diff --git a/src/utils/loading-message.ts b/src/utils/loading-message.ts index 3d24905..cf48d95 100644 --- a/src/utils/loading-message.ts +++ b/src/utils/loading-message.ts @@ -7,7 +7,7 @@ export default class { private msg!: Message; private isStopped = false; - constructor(channel: TextChannel, text: string) { + constructor(channel: TextChannel, text = 'cows! count \'em') { this.channel = channel; this.text = text; } @@ -53,7 +53,7 @@ export default class { })(); } - async stop(str?: string): Promise { + async stop(str = 'u betcha'): Promise { this.isStopped = true; if (str) { -- cgit v1.2.3