Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:8:7

˹Remember, O believers˺, when Allah promised you one of the two groups - that it would be yours - and you wished that the unarmed one would be yours. But Allah intended to establish the truth by His words and to eliminate the disbelievers  

And, remember, when God promised you one of the two parties, either the caravan or the band ˹of Meccan fighters˺, that it should be yours, and you longed, you were wishing, that other than the armed one, that is, ˹other than˺ the fighting one with the weapons, in other words, ˹you longed that˺ the caravan, should be yours, because it had fewer men and less reinforcements than the band ˹of Mecca fighters˺; but God willed that the truth be realised, ˹He willed˺ to manifest it, by His, preceding, words, that Islam should triumph; and to cut the root of the disbelievers, to the very last man, by extirpating them, and so He commanded you to fight against the band.
القرآن:٨:٧

وَإِذْ يَعِدُكُمُ اللَّهُ إِحْدَى الطَّائِفَتَيْنِ أَنَّهَا لَكُمْ وَتَوَدُّونَ أَنَّ غَيْرَ ذَاتِ الشَّوْكَةِ تَكُونُ لَكُمْ وَيُرِيدُ اللَّهُ أَنْ يُحِقَّ الْحَقَّ بِكَلِمَاتِهِ وَيَقْطَعَ دَابِرَ الْكَافِرِينَ  

{و} اذكر {إذ يعدكم الله إحدى الطائفتين} العير أو النفير {أنها لكم وتودُّون} تريدون {أن غير ذات الشوكة} أي البأس والسلاح وهي العير {تكون لكم} لقلة عددها ومدَدها بخلاف النفير {ويريد الله أن يُحق الحق} يظهر {بكلماته} السابقة بظهور الإسلام {ويقطع دابر الكافرين} آخرهم بالاستئصال فأمركم بقتال النفير.