Customize @On Decorator
Fredi100 opened this issue · comments
Alfred Emsenhuber commented
Adding the ability to further narrow down the On decorator.
Example:
@On('message','begins','!Foo') // Message begins with !Foo
private onCommandFoo(message: Message){
// ...
}
@On('message','equals','!help') // Message equals !help
private onCommandHelp(message: Message){
// ...
}
@On('message','contains','#bar') // Message contains #bar
private onHashtagBar(message: Message){
// ...
}
This way instead of having one onMessage
method which has to handle all commands that a user could send, there could be multiple methods for different commands.
Owen Gombas commented
Very interesting feature ! Thank’s I’m going to work on it :)
Alfred Emsenhuber commented
I have made a pull request regarding this feature. Maybe you can link the request to this issue.
Owen Gombas commented
I implemented the @guard (and the Prefix function) decorator !
The documentation is here! :)