Hi i read that there is a bracha before going to the toliet. this tells me that i can lechatchila make a bracha even if i need the toliet. example if i am not dying for the toliet but i will need to go in the next half hour i can say any bracha? however i read that if one says bircat hamazon and needed the toilet one should repeat it? please clarify these halachot for me
You’re correct that you’re not allowed to say a bracha if you need to go to the toilet. But what you are referring to is that they used to say this sentence to angels that they should wait and return to guard the person after he leaves the bathroom (Brachot 60a), but it’s not a bracha or prayer to Hashem, so it's no problem. In any event, already 500 years ago, the Shulchan Aruch (Or. Ch. 3, 1) wrote that people no longer recite this, for we are no longer on that level, to have angels accompanying us!