If all else fails: A friend and I almost literally tore the Moon Lord in half in no time at all last night.
She was using a Stardust Cell Staff and summoner gear, I was using a Vortex Beater with chlorophyte bullets.
My accessories: Ankh Shield, Sniper Scope, Destroyer Emblem, Fishron Wings and Cross Necklace, all Menacing. I could have dropped the wings too, since I was inside my Cosmic Car.
I didn't use any potions, apart from some healing ones. I also have a Rod of Discord, pretty nice to avoid the big beam o' death with.
The cells from the Stardust Cell Staff seemed to latch onto the Moon Lord's eyes, even when they were not open/active, and did lots of damage when they did open.
My Vortex Beater also did massive damage and thanks to the chloro bullets I could keep a reasonable safe distance from him, only having to worry about the big beam.
It felt really cheap, but hey, I'll take it.
We had our spawnpoint in a building where the nurse lives just in case. Try not to wait too long before visiting the nurse or heal up in another matter and like milk said, if you are going to die, make sure that the other person holds off his/her attacks and runs for it until you've respawned, so the Moon Lord doesn't get a chance to despawn.
I've killed the Moon Lord with a melee character but found that so much harder. I needed an arena for that, standing still in honey, surrounded by heart statues, that kind of stuff.
Being a ranger is a lot easier. Mage and Summoner too I bet. They all have endgame homing weapons.