owengombas / discord.ts

🤖 Create your discord bot by using TypeScript and decorators!
https://owencalvin.github.io/discord.ts/
324 stars 40 forks source link

Customize @On Decorator #3

Closed Fredi100 closed 4 years ago

Fredi100 commented 4 years ago

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.

owengombas commented 4 years ago

Very interesting feature ! Thank’s I’m going to work on it :)

Fredi100 commented 4 years ago

I have made a pull request regarding this feature. Maybe you can link the request to this issue.

owengombas commented 4 years ago

I implemented the @Guard (and the Prefix function) decorator ! The documentation is here! :)