Hi [NAME] welcome to this free user to user Alienware laptop discussion forum.  You have already found the problem to be loose mains plug into ac adapter's socket. Please replace with new Dell OEM 240 Watt ac adapter (DP/N) J938H. (1 Year Warranty Included)  The battery is either not being charged or near to end of life. Please create Windows 10 Battery Report: What It Is And How to Use It (lifewire.com) Compare full charge capacity with design capacity.  For the typical user, noticeable reduction in run time generally will be observed after 18 to 24 months. For a power user, reduction in run time generally may be experienced within 18 months. Dell recommends buying a new Dell OEM battery when the run time does not meet your needs. Dell Laptop Battery - Frequently Asked Questions | Dell UK  Dell Alienware m15 R4 Original XPS 15 (9500) 6-Cell 86Wh OEM Battery (DP/N) 69KF2, or Dell Alienware m15 R4 Original XPS 15 (9500) 3-Cell 56Wh OEM Battery (DP/N) 8FCTC.   Check battery manufacture year/month date beneath square matrix on white label is less than six months old.  Support for Alienware m15 R4 Troubleshooting includes Diagnostic-light LED codes. 
As the title suggests, I was just playing a game while the laptop was charging and the device suddenly shut down. The power button blinks red rapidly for a few seconds then shuts off. The device won’t turn on. In fact, when it’s done blinking it turns the light on the power cable off. I have to fidget with the power brick to get the light to turn back on on the cord but when I plug it into the laptop it flashes red again and then the light on the cord comes off. Any assistance would be appreciated. One thing to note is that the connector that plugs into the power brick has always been very loose; the slightest touch causes the light on the cord to come off. I’m not sure if I have a faulty power supply or something of that nature but any assurance will be greatly appreciated.
m15 R4, power button flashes red, no turn on