gatekeeper
gatekeeper copied to clipboard
Allow accessing underlying interaction as an escape hatch
Currently, there is no way (that I know of) to access the underlying interaction on a slash command. This would be useful in order to perform actions not yet supported by gatekeeper (eg: #18), without losing gatekeeper's niceties like auto-syncing commands.
Maybe expose it as a something like readonly nativeInteraction: Interaction
, to use the react convention for event handlers?
I think this is a good idea for the sake of productivity.
But there's a caveat: Gatekeeper uses an action queue system to ensure that interaction calls happen only once at a time, in the correct order, which is why there's no await
required on reply calls. Reading from the interaction is fine, but calling functions on it has a high chance of erroring if you're not careful.
I'll accept a PR for this, on the condition that this caveat is added in the comment for it.
Sure!! Having a way to drop to lower level brings its own challenges, and trying to mix both approaches would be crazy.
What if we added a whole different callback without the custom context? It's a little more work but the user wouldn't be able to mess with the context order of operations.
Something like this, maybe?
gatekeeper.addSlashCommand({
name: "search",
description: "Guess what…",
options: {...},
async nativeRun(interaction: Interaction) {...},
})
-- edit
missing the options
typings would be sad, though
Sure!! Having a way to drop to lower level brings its own challenges, and trying to mix both approaches would be crazy.
What if we added a whole different callback without the custom context? It's a little more work but the user wouldn't be able to mess with the context order of operations.
Something like this, maybe?
gatekeeper.addSlashCommand({ name: "search", description: "Guess what…", options: {...}, async nativeRun(interaction: Interaction) {...}, })
-- edit
missing the
options
typings would be sad, though
Actually, I think I like this. It aligns with some future plans I have with gatekeeper as well. If you want to add this into the library with the appropriate comments, I'll accept it. :slightly_smiling_face:
The missing options
types, I'll just call it a tradeoff for "needing to go lower level", honestly