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)
قَالَ رَسُولُ اللهِ ﷺ يَوْمَ بَدْرٍ إِذَا أَكْثَبُوكُمْ فَارْمُوهُمْ بِالنَّبْلِ وَلَا تَسُلُّوا السُّيُوفَ حَتَّى يَغْشَوْكُمْ