Several things explain your current state:
1) Too much MDMA. 500mg is not a normal amount to take in a night - I'd limit yourself to 100-150mg, 200-250mg if its a long night with more than one dose going on, but even that is putting a lot of stress on your body and brain. Also, if you thought it was okay to take such an amount over a night, you've probably abused MDMA in other ways - e.g. taking it too frequently, stick to rolling once a month at most, or it'll take its toll pretty quick.
2) A strong trip during your recovery period. After MDMA your body and brain need some rest, especially after such an excessive amount your brain is going to be really tired out, and throwing other drugs into the mix the next day is really going to worsen the load - sometimes even after a strong trip your brain can feel a bit frazzled and tired out for a few days, but taking a strong trip while on the MDMA hangover - ouch, that's going to leave you worse for wear for a good few days or a week or two. In my experience it's best to leave a 1-2 day rest period after you've rolled, if you must indulge in something, smoke some weed or drink a beer or two - and keep those to a minimum too ideally, give yourself room to recover.
3) Sleeping too long. We all know sleeping too little results in us feeling tired, worn out, confused, etc.. but sleeping too long does the same! You said you slept 24 hours, that's a long time to sleep and it's completely normal to feel pretty fried and slow after a sleep so long.
All 3 of these things, and any other factors you might not have mentioned have led to you feeling rather rough. You slept 24 hours - was that because you stayed up the entire previous two days? If so that's a major factor too and could have resulted in this feeling on its own.
You'll need anywhere from a few days to 2-3 weeks to fully recover depending on the severity of it. Don't panic though, it's normal to experience such effects - but it's a sign to be more careful in future. Don't go taking MDMA too frequently or in such large amounts and give yourself proper rest and recuperation after a roll - but avoid *too* much too.