💡 Tip
bot.on, bot.hears, and their siblings already let you filter down context objects without having to do large if statements. However, sometimes this just isn't enough, and you may want to do some extra branching inside a handler.
Did you know that you can do this via Has Checks? They let you find out lots of things for a context objects:
- Is there a start command in the update? ctx.hasCommand("start").
- Does the text match a regular expression? ctx.hasText(/regex/).
- Does the context match the filter query channel_post::hashtag? ctx.has("channel_post::hashtag").
- Many more!
This is especially useful inside the conversations plugin.
bot.on, bot.hears, and their siblings already let you filter down context objects without having to do large if statements. However, sometimes this just isn't enough, and you may want to do some extra branching inside a handler.
Did you know that you can do this via Has Checks? They let you find out lots of things for a context objects:
- Is there a start command in the update? ctx.hasCommand("start").
- Does the text match a regular expression? ctx.hasText(/regex/).
- Does the context match the filter query channel_post::hashtag? ctx.has("channel_post::hashtag").
- Many more!
This is especially useful inside the conversations plugin.