Lily Wonhalf
Lily Wonhalf
Explore posts from servers
SIASapphire - Imagine a framework
Created by Lily Wonhalf on 10/8/2023 in #sapphire-support
Allow or prevent command execution
I found this file in the framework: https://github.com/sapphiredev/framework/blob/main/src/listeners/application-commands/chat-input/CorePreChatInputCommandRun.ts And it very much looks like that's the one responsible for letting commands be executed or not. I want to accomplish something similar, but if I create my own listener for the same event, it will not prevent the commands that are being authorized by the core listener, will it? How would that work? And how can I accomplish what I want? Thank you!
53 replies
SIASapphire - Imagine a framework
Created by Lily Wonhalf on 8/20/2023 in #sapphire-support
Passing a new parameter to commands
Heyo! I am converting my bots to Sapphire, and on one of them, I pass the entity manager of my ORM to each command as I call them so I don't create too many (or else it creates a memory leak). So basically, I create an entity manager every time there's an event, instead of every time I need one. That worked fine before Sapphire, because I was the one calling my commands. But now, I am not anymore! So I thought about a way to do it. I could extend the container and add an "em" key to it. Then, iirc, there's an event Sapphire emits before an application command is called. I could plug into that event to initialize the entity manager in the container, and destroy it after the command is done (if there's an event for that too). Do you think that's a good approach? If not, what would you suggest? Thank you!
118 replies