diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-09 21:50:03 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-09 21:50:03 -0400 |
commit | 22731b8bf1c66e4d66ee692cd2a650d609c206e0 (patch) | |
tree | e8e9ce0ad467b34abfc5c82ca8129aa51f644700 /src | |
parent | 20ec27eac550825a596e66220e887fa74a851f6a (diff) | |
download | tanzanite-22731b8bf1c66e4d66ee692cd2a650d609c206e0.tar.gz tanzanite-22731b8bf1c66e4d66ee692cd2a650d609c206e0.tar.bz2 tanzanite-22731b8bf1c66e4d66ee692cd2a650d609c206e0.zip |
warnings
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/utils/BushLogger.ts | 2 | ||||
-rw-r--r-- | src/listeners/other/promiseRejection.ts | 7 | ||||
-rw-r--r-- | src/listeners/other/uncaughtException.ts | 7 | ||||
-rw-r--r-- | src/listeners/other/warning.ts | 22 |
4 files changed, 33 insertions, 5 deletions
diff --git a/src/lib/utils/BushLogger.ts b/src/lib/utils/BushLogger.ts index c2a9989..f00c19c 100644 --- a/src/lib/utils/BushLogger.ts +++ b/src/lib/utils/BushLogger.ts @@ -156,7 +156,7 @@ export class BushLogger { .setDescription(`**[${header}]** ${this.#parseFormatting(this.#stripColor(newContent), '', true)}`) .setColor(util.colors.warn) .setTimestamp(); - await this.channelLog({ embeds: [embed] }); + await this.channelError({ embeds: [embed] }); } /** diff --git a/src/listeners/other/promiseRejection.ts b/src/listeners/other/promiseRejection.ts index 130daa3..dc21c3f 100644 --- a/src/listeners/other/promiseRejection.ts +++ b/src/listeners/other/promiseRejection.ts @@ -10,8 +10,11 @@ export default class PromiseRejectionListener extends BushListener { } public override async exec(error: Error): Promise<void> { - // eslint-disable-next-line @typescript-eslint/no-base-to-string - void client.console.error('promiseRejection', `An unhanded promise rejection occurred:\n${error.stack ?? error}`, false); + void client.console.error( + 'promiseRejection', + `An unhanded promise rejection occurred:\n${typeof error == 'object' ? error.stack : error}`, + false + ); if (!error.message.includes('reason: getaddrinfo ENOTFOUND canary.discord.com')) void client.console.channelError({ embeds: [await CommandErrorListener.generateErrorEmbed({ type: 'unhandledRejection', error: error })] diff --git a/src/listeners/other/uncaughtException.ts b/src/listeners/other/uncaughtException.ts index 47db37f..4ba47bd 100644 --- a/src/listeners/other/uncaughtException.ts +++ b/src/listeners/other/uncaughtException.ts @@ -10,8 +10,11 @@ export default class UncaughtExceptionListener extends BushListener { } public override async exec(error: Error): Promise<void> { - // eslint-disable-next-line @typescript-eslint/no-base-to-string - void client.console.error('uncaughtException', `An uncaught exception occurred:\n${error?.stack ?? error}`, false); + void client.console.error( + 'uncaughtException', + `An uncaught exception occurred:\n${typeof error == 'object' ? error.stack : error}`, + false + ); void client.console.channelError({ embeds: [await CommandErrorListener.generateErrorEmbed({ type: 'uncaughtException', error: error })] }); diff --git a/src/listeners/other/warning.ts b/src/listeners/other/warning.ts new file mode 100644 index 0000000..d85e9e3 --- /dev/null +++ b/src/listeners/other/warning.ts @@ -0,0 +1,22 @@ +import { BushListener } from '@lib'; +import CommandErrorListener from '../commands/commandError'; + +export default class WarningListener extends BushListener { + public constructor() { + super('warning', { + emitter: 'process', + event: 'warning' + }); + } + + public override async exec(error: Error): Promise<void> { + void client.console.warn('warning', `A warning occurred:\n${typeof error == 'object' ? error.stack : error}`, false); + void client.console.channelError({ + embeds: [ + (await CommandErrorListener.generateErrorEmbed({ type: 'unhandledRejection', error: error })) + .setColor(util.colors.warn) + .setTitle('A Warning Occurred') + ] + }); + } +} |