Solved! Laptop won't power on unless plugged in (or with battery removed)

Feb 1, 2022
My laptop will only power on when it is plugged in. If I unplug it, it instantly switches off. It also switches off at random when I'm trying to use it.

After looking for advice online I tried turning on the laptop with the battery removed, but it wouldn't turn on.