I have done something to the muscle in the front of my shoulder, i have rested for 4 days but is there anything else I can do to prevent it happening again. Also how long should I rest for?
You should rest until its gone, and when you workout make sure to warm up properly and dont progress to the more advanced exercises too fast.
Warm up is important but train your external rotations. Also do Face Pulls. Work into this topic, look at the studies and you will find out how to get healthy shoulders. I would recommend AthleanX on Youtube for shoulder health.