
Certified GKH Gardening Expert
It looks like parts of the stem may have rot issues. In this case the discolored parts on the stem would feel softer than the rest of the stem. This is often caused by overwatering, but can be caused by fungal or bacterial diseases as well. The rot doesn't look like it has reached the roots, so the plant can probably be saved. Follow the instructions in this article:
https://www.gardeningknowhow.com/ornamental/cacti-succulents/scgen/cactus-going-soft.htm
Also check this guide to cactus diseases:
https://plantdiseasehandbook.tamu.edu/landscaping/flowers/cacti-and-succulents/