#Throwing errors in commands/subcommands

1 messages · Page 1 of 1 (latest)

cerulean nymph
#

Just curious if there is a way to throw an error in an application command/subcommand and have it handled by the chatInputCommandDenied listener, similar to how preconditions work. Some kind of this.error that can be sent and handled by the listener. Does this exist or can I write something to do that?

fathom boneBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

misty cipher
#

chatInputCommandDenied is exclusively for preconditions that return this.error(). However, you have the chatInputCommandError event to handle errors thrown by commands.

From source code:

cerulean nymph
#

Gotcha, so I could do some similar kind of listener for chatInputCommandError, and then just make my commands throw an error?

cerulean nymph
#

Alright, I'll have a mess about and see if I can get something to work, thanks

#

I've quickly just thrown a throw 'Test' into a command and seems that the chatInputCommandSuccess is being emitted, not chatInputCommandError (as the debug logger is going off, not any code I wrote for the error)

fair sage
#

For subcommands it's a separate listener

#

chatInputSubcommandError if i remember correctly but there is an SubcommandsEvents constant exported from the plugin so easier to just use that

#

Likewise for subcommand preconditions are their own event

#

CC @misty cipher

cerulean nymph
#

Ahh, gotcha

#

Yep, now that's working perfectly, awesome

#

Also assumg that means I'll need to also have a chatInputSubommandDenied listener for subcommand preconditions?

misty cipher
#

Oh right, I missed the subcommand part, sorry 😅