Interaction create and custom commands
I have a system with shortcuts (basically a command that punishes a user with a defined reason and duration, e.g something like ,spam <user>) and I'm trying to port them to my sapphire bot, however, I'm unsure if adding an interaction create event for chat input commands would mess with sapphire's handlers. My guess is that It won't if it can't find a command that matches the name of a global command but I'd still like to make sure. Can anyone confirm this?
Solution:Jump to solution
Ah no you can't do that through sapphire command classes but you can implement the Events. UnknownChatInputCommand event instead of interactionCreate which will ensure that the interaction is at least a chat input command and not another type of interaction.
9 Replies
it wouldnt, both listeners would run at more-or-less the same time. However why not just use Sapphire's interactionCreate handler and sapphire's commands? From your description I see no reason why you couldnt
They're guild specific commands, and their data is in the database. You can create and delete them as you please
They're not set, the user can fully customize them
/shortcuts add <name> <description> <punishment> <reason> [duration] [delete-previous-messages] [additional-information]
This type of thing, then that data is used to register a guild command which can be ran as a slash or message command
Idk how I could accomplish this with sapphire's command class lolSolution
Ah no you can't do that through sapphire command classes but you can implement the Events. UnknownChatInputCommand event instead of interactionCreate which will ensure that the interaction is at least a chat input command and not another type of interaction.
And that also won't run in parallel with interactionCreate but shortly after it
Oh, I see. That works too, as long as the speed isn't affected by like a minute
Far far far from it
Less than a second probably
That should work fine. As long as there's not a noticeable delay as rn it's really fast and I don't wanna ruin that
Oh btw, quick question, is it possible to change the error message an argument throws without having to extend the class/override the default one?
I'm assuming not but I thought i'd make sure anyway
Implement
MessageCommandError
/ ChatInputCommandError
etc, similar to https://sapphirejs.dev/docs/Guide/preconditions/reporting-precondition-failure but those different events. Use error.identifier
to identify the type of error, then send your own custom message.Sapphire Framework
Reporting precondition failure | Sapphire
When a precondition fails, it's usually important for the user to know why. For example, if they hit a cooldown or lack
Oh right, I forgot that is a property. Thanks