Well, first off, try to understand what made them sad. Maybe have a heart-to-heart talk without judgment.
I think it's important to show genuine empathy. Maybe bring them something they like or suggest doing an activity they enjoy. Just be cautious about the NSFW part and ensure it doesn't make the situation worse.