well my gf and my friend had sex with eachother so I don't really know what to do
Forgive her if she asks for forgiveness..
Forgive him if he asks for forgiveness..
That does not mean you have to continue your bf/gf relationship with her.. If she has shown herself to be so unfaithful and to be unfaithful with a friend of yours then she is not the girl for you if you want a good long term husband/wife relationship..
As for your friend a man who would cheat with his friends g/f is no loyal friend.. You can be at peace with him as a person in your community but he has proven himself not to be a trustworthy friend.