diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-06-02 18:10:17 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-06-02 18:10:17 -0400 |
commit | 5f4f28903b2f3428e54ed74417fc06e8eeb58ebf (patch) | |
tree | 6c31807fa3de0bb142ae2bfc7496ee96663a81eb /src/listeners/contextCommands | |
parent | 34b55d206c5048b4abacf68c663261f494c888a2 (diff) | |
download | tanzanite-5f4f28903b2f3428e54ed74417fc06e8eeb58ebf.tar.gz tanzanite-5f4f28903b2f3428e54ed74417fc06e8eeb58ebf.tar.bz2 tanzanite-5f4f28903b2f3428e54ed74417fc06e8eeb58ebf.zip |
feat(errorHandler): ansi colors
Diffstat (limited to 'src/listeners/contextCommands')
-rw-r--r-- | src/listeners/contextCommands/contextCommandError.ts | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/listeners/contextCommands/contextCommandError.ts b/src/listeners/contextCommands/contextCommandError.ts index 45e1114..e020f2b 100644 --- a/src/listeners/contextCommands/contextCommandError.ts +++ b/src/listeners/contextCommands/contextCommandError.ts @@ -44,7 +44,7 @@ export default class ContextCommandErrorListener extends BushListener { `contextCommandError`, `an error occurred with the <<${command}>> context command in <<${channel}>> triggered by <<${ interaction?.user?.tag - }>>:\n${util.formatError(error)}`, + }>>:\n${util.formatError(error, true)}`, false ); @@ -58,7 +58,7 @@ export default class ContextCommandErrorListener extends BushListener { type: 'command-log' }); - void client.logger.channelError({ embeds: [errorEmbed] }); + void client.logger.channelError({ embeds: errorEmbed }); if (interaction) { if (!client.config.owners.includes(interaction.user.id)) { @@ -66,14 +66,14 @@ export default class ContextCommandErrorListener extends BushListener { ...options, type: 'command-user' }); - void interaction?.reply({ embeds: [errorUserEmbed] }).catch(() => null); + void interaction?.reply({ embeds: errorUserEmbed }).catch(() => null); } else { const errorDevEmbed = this._generateErrorEmbed({ ...options, type: 'command-dev' }); - void interaction?.reply({ embeds: [errorDevEmbed] }).catch(() => null); + void interaction?.reply({ embeds: errorDevEmbed }).catch(() => null); } } } catch (e) { @@ -90,16 +90,18 @@ export default class ContextCommandErrorListener extends BushListener { channel?: string; haste: string[]; stack: string; - }): EmbedBuilder { - const embed = new EmbedBuilder().setColor(util.colors.error).setTimestamp(); + }): EmbedBuilder[] { + const embeds = [new EmbedBuilder().setColor(util.colors.error)]; if (options.type === 'command-user') { - return embed + embeds[0] .setTitle('An Error Occurred') .setDescription( `Oh no! ${ options.command ? `While running the command ${util.format.input(options.command.id)}, a` : 'A' }n error occurred. Please give the developers code ${util.format.input(`${options.errorNum}`)}.` - ); + ) + .setTimestamp(); + return embeds; } const description: string[] = []; @@ -113,11 +115,11 @@ export default class ContextCommandErrorListener extends BushListener { description.push(...options.haste); - embed.addFields([{ name: 'Stack Trace', value: options.stack.substring(0, 1024) }]); - if (description.length) embed.setDescription(description.join('\n').substring(0, 4000)); + embeds.push(new EmbedBuilder().setColor(util.colors.error).setTimestamp().setDescription(options.stack.substring(0, 4000))); + if (description.length) embeds[0].setDescription(description.join('\n').substring(0, 4000)); if (options.type === 'command-dev' || options.type === 'command-log') - embed.setTitle(`ContextCommandError #${util.format.input(`${options.errorNum}`)}`); - return embed; + embeds[0].setTitle(`ContextCommandError #${util.format.input(`${options.errorNum}`)}`); + return embeds; } } |