How do I find out if a particular animation existed?

Godot Version

4.2.2

Question

I am planning to write an Enemy script that would be shared with multiple type of enemies. Some would not have certain animations and I would like to know how to check for them.

What I’m trying to do:

if this animation exist for this game object, play it. Otherwise ignore.

I am using AnimatedSprite2D for my current project. I have checked the documentation and found nothing. I thought it was the get_animation() but it comes back an error once I put the animation I am looking for in between the brackets as a string.

sprite_frames.has_animation(...)

Invalid call. Nonexistent function ‘has_animation’ in base ‘AnimatedSprite2D’.

You should use my_animated_sprite.sprite_frames.has_animation(...)