S-IAF
Join ServerSapphire - Imagine a framework
sapphire-support
Is there a way to prevent fetching information both in the precondition and the command itself?
GGavan12/13/2022
I need to fetch the same data to resolve a precondition, as I'll need later in the command. Is there a way to prevent fetching this twice?
LLioness10012/14/2022
No, not with preconditions. I was thinking about something like it a while ago but never got the time to work on it and forgot
https://discord.com/channels/737141877803057244/737142774738190377/1024108953577201734
https://discord.com/channels/737141877803057244/737142774738190377/1024108953577201734
LLioness10012/14/2022
If you want to be really really hacky, you could also attach something to the
interaction
object directly, as that's reused between preconditions and the commandLLioness10012/14/2022
kind of like how you would assign to
req
in an expressjs middlewareGGavan12/14/2022
@Lioness100 Ok, thanks!
For the time being I just kinda invented a new 'guard' primitive for myself and am doing things like
For the time being I just kinda invented a new 'guard' primitive for myself and am doing things like
public async chatInputRun(interaction: Command.ChatInputInteraction) {
...
if(!await guardIsValidTopic(interaction, topicResult)) return;
LLioness10012/14/2022
š
KKrish12/14/2022
you can also make an object which will store the response according to the interaction id and reusing it in your command, and finally remove the entry from the object