hasEntity method

bool hasEntity(
  1. MessageEntityType type
)

Checks if the message contains any entities of a specific type.

Example:

if (ctx.hasEntity(MessageEntityType.url)) {
  await ctx.reply('Found a URL!');
}

Implementation

bool hasEntity(MessageEntityType type) {
  final messageEntities = entities;
  if (messageEntities == null) return false;

  return messageEntities.any((entity) => entity.type == type);
}