findObjectWithName method
Find an object in this bot with a specific name and type.
-
{name} is the name of the object that you want to find.
-
{type} is the type of object that you want to find.
Implementation
Future<BotObject?> findObjectWithName(
{required String name, required BotObjectType type}) async {
List<BotObject>? allObjects = await findObjects(type: type);
try {
GetIt.I<BotnoiClient>().finishedSuccessfully();
return allObjects!.firstWhere((element) =>
element.objectName == BotObjectNamer.byAction(name, type));
} catch (e) {
GetIt.I<BotnoiClient>().finishedFailed();
return null;
}
}