Hi Human and welcome!!

I do not know if you can totally avoid having unpleasant dreams. Everyone does on occasion.

I would suggest that you learn how to have Lucid dreams, then, if you find a dream unpleasant, you can just change it or end it.