Quite often the MacBook stops charging because the power supply is broken. You can check it by simply plugging in a known working accessory. Or try changing the power outlet. If you've tried everything but your MacBook stubbornly refuses to charge, then it's best to contact the experts at https://howly.com/computers/brand-apple/series-macbook-pro/ - the problem could be either in the battery or in the motherboard.
The first thing to check is that there are no small foreign objects or dirt in the charging connector. Visually check the connector on the computer and the charger and, if there is dirt, remove it. Before doing so, of course, turn off the computer.