If you want to determine at the command line if an AC charger is connected, you can use
pmset to find out.
pmset -g ac
When a charger is connected, you get this:
Wattage = 85W Revision = 0x0000 AdapterID = 0x0100 Family Code = 0x0085 Serial Number = 0x00225c8e
If no adapter is connected, you get:
No adapter attached.
I've also seen cases where macOS seems like it can't communicate with the charger properly and you get this as output. Unplugging and re-plugging may resolve this.
Revision = 0x0000 AdapterID = 0x0000 Family Code = 0x0000 Serial Number = 0x0000000