owengombas / discord.ts

🤖 Create your discord bot by using TypeScript and decorators!

Home Page:https://owencalvin.github.io/discord.ts/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Customize @On Decorator

Fredi100 opened this issue · comments

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.

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

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

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