Custom Hook before a Piece being called/run
Is there something like
beforeRun hook where we can register custom function to be called. I'd imagine something like a middleware before the piece messageRun or chatInputRun being called. What I'm trying to do is to add a logger that is able to read the piece name and it's message/content. Currently doing it by adding the code right on the beginning of the run function, in which is not efficient and easy to forget.1 Reply
You can use listeners with specific events: https://www.sapphirejs.dev/docs/Documentation/api-framework/#events
I.e. for
messageRun it would be Events.MessageCommandRun (messageCommandRun)
and for chatInputRun it would be Events.ChatInputCommandRun (chatInputCommandRun)