The Prophet ﷺ said at the battle of Badr: When they come near you shoot arrows at them; and do not draw swords at them until they come near you. (Using translation from Abū Dāʾūd 2664)
"إذا أَكْثبوكم فارمُوهُمْ بالنَّبل ولا تسلُّوا السُّيوفَ حتى يغشَوْكم".