Hi iulian103,
Thanks for coming to Apple Support Communities for help today with your iPhone X. It sounds like it won't come on unless it has a charger plugged in.
Instead of plugging it in the charger, have you ever tried a force restart?
"Press and quickly release the volume up button, press and quickly release the volume down button, then press and hold the side button. When the Apple logo appears, release the button."
If that doesn't resolve the issue permanently, you can next try restoring to factory settings through a computer: Restore your iPhone, iPad, or iPod to factory settings. Just be sure you have a backup created as suggested under "Get your device ready".
This puts a fresh install of iOS on your device. Then, test this issue without your backup restored. If it seems to work as expected, restore the backup and test again. Restore your iPhone, iPad, or iPod touch from a backup.
Let us know how it goes.
Have a fantastic day!