"I will deal loyally with Hanun the son of Nahash, as his father dealt loyally with me” (v2). King David approached the Ammonites with the idea of diplomacy and perhaps an alliance, but the advisors of the new Ammoniate king were suspicious of his motives (v3). Their shameful treatment of the Israelite visitors (v3-4) led to war, and the Ammonites were defeated by the newly united tribes of Israel. By rejecting David’s overtures of peace, the Ammonites invited destruction.
“Be of good courage …” (v12). Courage does not mean provoking unnecessary battles (like the Ammonites), but being ready to face difficulties, trusting that God will “do what seems good to him” (v12).