hasText method

bool hasText(
  1. String text, {
  2. bool caseSensitive = false,
})

Checks if the message contains a specific text.

Example:

if (ctx.hasText('hello')) {
  await ctx.reply('Hi there!');
}

Implementation

bool hasText(String text, {bool caseSensitive = false}) {
  final messageText = this.text;
  if (messageText == null) return false;

  if (caseSensitive) {
    return messageText.contains(text);
  } else {
    return messageText.toLowerCase().contains(text.toLowerCase());
  }
}