interaction-kit icon indicating copy to clipboard operation
interaction-kit copied to clipboard

Custom transformers for command options

Open Rodentman87 opened this issue 3 years ago • 0 comments

Describe the request Pass a transform function to an option to have it transform the value of the option before it's passed to the command's handler. This would be useful for things like:

  • Cleaning up user input
  • Pulling an object from a database
  • Converting to a Date (or other object)

Example Usage I have a command for reminders that takes a date option for when the reminder should happen. Currently, this could be a string option that's parsed inside the command's handler. With a transformer, the Date can be parsed outside of the command handler, leading to cleaner code inside the handler and a better separation of concerns. By having the transformer exist as a function on the option, this allows it to be re-used on other options more easily.

Does this increase our chances of an iCrawl Acquisition? Maybe

Rodentman87 avatar Apr 24 '22 01:04 Rodentman87