aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-16 09:20:49 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-16 09:20:49 -0500
commitefb6f1f8a5137500d1608a896d6242fc816f5693 (patch)
tree333761060ebc96f4cb4269881557265f73e38fd8 /src
parent9a2002a1368ba9ae53ef7419a87213f8efd142ee (diff)
downloadtanzanite-efb6f1f8a5137500d1608a896d6242fc816f5693.tar.gz
tanzanite-efb6f1f8a5137500d1608a896d6242fc816f5693.tar.bz2
tanzanite-efb6f1f8a5137500d1608a896d6242fc816f5693.zip
make command error more safe
Diffstat (limited to 'src')
-rw-r--r--src/listeners/commands/commandError.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts
index 9e7417d..ac81bae 100644
--- a/src/listeners/commands/commandError.ts
+++ b/src/listeners/commands/commandError.ts
@@ -19,13 +19,13 @@ export default class CommandErrorListener extends BushListener {
public static async handleError(
...[error, message, _command]: BushCommandHandlerEvents['error'] | BushCommandHandlerEvents['slashError']
) {
- const isSlash = message.util!.isSlash;
+ const isSlash = message.util.isSlash;
const errorNum = Math.floor(Math.random() * 6969696969) + 69; // hehe funny number
const channel =
message.channel?.type === 'DM'
- ? (message.channel as DMChannel)!.recipient.tag
- : (message.channel as GuildTextBasedChannel)!.name;
- const command = _command ?? message.util?.parsed?.command;
+ ? (message.channel as DMChannel)?.recipient.tag
+ : (message.channel as GuildTextBasedChannel)?.name;
+ const command = _command ?? message.util.parsed?.command;
client.sentry.captureException(error, {
level: Severity.Error,
@@ -34,11 +34,11 @@ export default class CommandErrorListener extends BushListener {
'command.name': command?.id,
'message.id': message.id,
'message.type': message.util.isSlash ? 'slash' : 'normal',
- 'message.parsed.content': message.util.parsed!.content,
+ 'message.parsed.content': message.util.parsed?.content,
'channel.id':
- message.channel!.type === 'DM'
- ? (message.channel as DMChannel)!.recipient.id
- : (message.channel as GuildTextBasedChannel)!.id,
+ message.channel?.type === 'DM'
+ ? (message.channel as DMChannel)?.recipient.id
+ : (message.channel as GuildTextBasedChannel)?.id,
'channel.name': channel,
'guild.id': message.guild?.id,
'guild.name': message.guild?.name,
@@ -50,7 +50,7 @@ export default class CommandErrorListener extends BushListener {
`${isSlash ? 'slashC' : 'c'}ommandError`,
`an error occurred with the <<${command}>> ${isSlash ? 'slash ' : ''}command in <<${channel}>> triggered by <<${
message?.author?.tag
- }>>:\n${error?.stack}` || error,
+ }>>:\n${error?.stack ?? <any>error}`,
false
);