Chosen Solution

If my phone is not charging it will just keep shutting down but when I charge it it’s fine.

This is most likely a broken battery - this should not be happening. I’d suggest replacing it since they’re quite cheap.