Contentment is the antidote to complaining. (Many sources)

Someone else has said that the antidote is being grateful. In any case, no one likes to be around people who are disagreeable, always critical of others, and dissatisfied with their circumstances. To counter such unpleasant behavior, don’t waste time using logic. Demonstrate your own gratitude for life and contentment with what God has given you.

The fear of the Lord leads to life; then one rests content (Proverbs 19:23).