Joshua and the Hebrew children had made a major faux pas. (Alright, let's just call it what it was: sin.) Not surprisingly, God confronted them about it. But God is so big that when we sin against him or each other, or even ourselves, he doesn't want us to stay in our mess.
Sure, God wants us to repent we sin, and clean up our act, but he helps us to stand. He's not surprised when we sin. God's ALWAYS got a plan for us.
Then the Lord said to Joshua, “Don’t be afraid or discouraged; take the entire army and go to Ai, for it is now yours to conquer. I have given the king of Ai and all of his people to you. (Joshua 8:1 TLB)

1. REPENT of any sin.
2. ACCEPT God's
Sovereignty and will.
3. FOLLOW God's
directions exactly.
4. TRUST God to do what
he says he will do.
The Apostle Paul puts it this way:
13 For it is God who is working in you, enabling you both to desire and to work out His good purpose. 14 Do everything without grumbling and arguing, 15 so that you may be blameless and pure, children of God who are faultless in a crooked and perverted generation, among whom you shine like stars in the world.
(Phillipians 2:13-15)