Minecraft Server using AWS EC2 Instance : how to check if someone is on the server ? Lambda function

I have a server running, and I schedule the start every friday at 19 PM, and all is working.

Now I want an event that triggers a Lambda function that checks if someone is on the server. If no one is there, I want to stop the instance.

How can I do that ? Someone know how to do it using Lambda Function ?

Thank you :3

I dont know how to check if someone is in my server using Lambda functions of AWS