aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions/discord-akairo
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-02 18:10:17 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-02 18:10:17 -0400
commit5f4f28903b2f3428e54ed74417fc06e8eeb58ebf (patch)
tree6c31807fa3de0bb142ae2bfc7496ee96663a81eb /src/lib/extensions/discord-akairo
parent34b55d206c5048b4abacf68c663261f494c888a2 (diff)
downloadtanzanite-5f4f28903b2f3428e54ed74417fc06e8eeb58ebf.tar.gz
tanzanite-5f4f28903b2f3428e54ed74417fc06e8eeb58ebf.tar.bz2
tanzanite-5f4f28903b2f3428e54ed74417fc06e8eeb58ebf.zip
feat(errorHandler): ansi colors
Diffstat (limited to 'src/lib/extensions/discord-akairo')
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index c5a5b30..5c641b6 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -685,9 +685,9 @@ export class BushClientUtil extends ClientUtil {
* @param error
*/
public async handleError(context: string, error: Error) {
- await client.console.error(_.camelCase(context), `An error occurred:\n${util.formatError(error)}`, false);
+ await client.console.error(_.camelCase(context), `An error occurred:\n${util.formatError(error, true)}`, false);
await client.console.channelError({
- embeds: [await CommandErrorListener.generateErrorEmbed({ type: 'unhandledRejection', error: error, context })]
+ embeds: await CommandErrorListener.generateErrorEmbed({ type: 'unhandledRejection', error: error, context })
});
}
@@ -1077,17 +1077,18 @@ export class BushClientUtil extends ClientUtil {
/**
* Formats an error into a string.
* @param error The error to format.
+ * @param colors Whether to use colors in the output.
* @returns The formatted error.
*/
- public formatError(error: Error | any): string {
+ public formatError(error: Error | any, colors = false): string {
if (!error) return error;
if (typeof error !== 'object') return String.prototype.toString.call(error);
if (
this.getSymbols(error)
.map((s) => s.toString())
- .includes('Symbol(util.inspect.custom)')
+ .includes('Symbol(nodejs.util.inspect.custom)')
)
- return error.inspect();
+ return this.inspect(error, { colors });
return error.stack;
}