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:71

But if they intend to betray you - then they have already betrayed Allah before, and He empowered ˹you˺ over them. And Allah is Knowing and Wise.  

And if they, the captives, desire to betray you, through words which they speak ˹to you˺, they have betrayed God before, before Badr, through unbelief; but He has given ˹you˺ power over them, at Badr, through slaying and capture, so let them anticipate the like if they return ˹to betrayal˺; and God is Knower, of His creatures, Wise, in His actions.
القرآن:٨:٧١

وَإِنْ يُرِيدُوا خِيَانَتَكَ فَقَدْ خَانُوا اللَّهَ مِنْ قَبْلُ فَأَمْكَنَ مِنْهُمْ ۗ وَاللَّهُ عَلِيمٌ حَكِيمٌ  

{وإن يريدوا} أي الأسرى {خيانتك} بما أظهروا من القول {فقد خانوا الله من قبل} قبل بدر بالكفر {فأمكن منهم} ببدر قتلا وأسرا فليتوقعوا مثل ذلك إن عادوا {والله عليم} بخلقه {حكيم} في صنعه.