Here is a trustworthy saying: If we died with him, we will also live with him; if we endure, we will also reign with him. If we disown him, he will also disown us; if we are faithless, he will remain faithful, for he cannot disown himself. (2 Timothy 2:11-13)
Moses did it himself. David got it done through someone else. We are talking of nothing else but murder. They did it after knowing God intimately (David especially) and they had to pay the price for it. Both went through a period of spiritual wilderness experience. But the thing that perplexes many is that God still used them for his purposes. Now that's something great. But God 's love is so amazing; none can truly fathom it's dimensions. And so these two could again do great things for God. God uses many for the building of his kingdom, but sometimes the chosen ones make light of these blessings and act as if they could do anything and everything and then they fail. Overconfidence was the undoing of Joshua too; he gained a great victory at Jericho, but failed in the conquest of Ai, a smaller target compared to Jericho. He failed because there was sin in his camp. Sin brings failure, but failure is not final and rooting out sin can again make God's face shine upon the chosen one. So Joshua conquered Ai after sin was rooted out of his camp. The wilderness experience is tough, but God does not leave nor forsake according to his everlasting promise and his showers of mercy can be felt in the wilderness too, though they may be sparse. Just an indication from him that he has not abandoned.
A few verses to remember in this context.....
In a large house there are articles not only of gold and silver, but also of wood and clay; some are for noble purposes and some for ignoble. If a man cleanses himself from the latter, he will be an instrument for noble purposes, made holy, useful to the Master and prepared to do any good work. (2 Timothy 2:20, 21)
"I am the vine; you are the branches. If a man remains in me and I in him, he will bear much fruit; apart from me you can do nothing. (John 15:5)
But thanks be to God, who always leads us in triumphal procession in Christ and through us spreads everywhere the fragrance of the knowledge of him. (2 Corinthians 2:14)
Much to learn for all those who are chosen to carry on the work that Jesus started. Best to look to the Master at all times and follow in his footsteps.