I'm using a battery as my power supply. Is there any command or library to check the battery voltage? I want to monitor the battery discharge.
You will need to add external circuitry if you want to monitor the battery voltage.
As a minimum you will need an ADC (Analog to Digital Converter) and a pair of resistors to convert the battery voltage range to a Pi safe 3V3.
You will then need to write software to read the ADC.