I can very much relate to this. I've probs failed a module because I've been very lazy last semester. My stakes are a bit lower than yours, so I feel fortunate. But look, it's important to remember that setbacks happen, and they provide an opportunity for growth and learning. There's the possibility that you did better than you imagine, so maybe no need to resit after all. But if you do resit, developing a study plan and committing to it will help achieve better results in your resits.
Reach out to your professors or tutors for guidance and assistance. They can provide valuable advice on how to prepare for your resits and offer additional resources to help you better understand the material.
Reflect on your study techniques and identify areas where you can make improvements. Consider creating a study schedule, breaking down your workload into manageable chunks.