It sounds like you've managed to make it worse over time. I think the best thing you can do for your phone is return it to stock.
- The first step to do that is figure out for sure what the model is. I'd try using the imei and one of the many online sources that give you info about your phone based on imei. use Google search, one example is this one:
http://sndeep.info/en
You can triple check the imei you got from the box and the software with the imei that should be printed on the inside of the SIM tray. just pop out the tray and look for the tiny numbers.
You can also use serial number to check with on the websites.
- After you get the model, get your stock ROM from one of the site that hosts them, find them here:
http://forum.xda-developers.com/moto-x/general/info-tip-web-sites-official-leaked-roms-t2923347
You can probably use the latest version of the stock ROM (probably 4.4.4) since you're obviously bootloader unlocked, but make sure you don't use a downgrade to a firmware than the most up-to-date one you had.
- Then flash back to stock with RSDLite, you can use this guide:
http://forum.xda-developers.com/moto-x/general/guide-moto-x-return-to-100-stock-using-t2446515
If the phone works fine after all that but the problem of rebooting when plugged in to charger still persists, I'd suspect a hardware issue. (BTW if you haven't tried different chargers, try that too).